00:00:00 --- log: started forth/19.12.29 02:27:57 --- quit: dave0 (Quit: dave's not here) 05:15:35 --- quit: smokeink (Read error: Connection reset by peer) 05:35:15 --- join: dddddd joined #forth 06:11:29 --- quit: iyzsong (Quit: ZNC 1.7.1 - https://znc.in) 06:21:30 --- quit: rcabaco (Ping timeout: 245 seconds) 08:36:28 --- join: learning joined #forth 08:37:03 finding it hard to get help with beginner problems in forth. right now im just trying to append to a file 08:38:01 ive been trying to follow this: https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Files-Tutorial.html 08:42:25 --- quit: jsoft (Ping timeout: 240 seconds) 09:32:54 --- join: Tony_Sidaway joined #forth 09:34:38 learning, hi, you still there? I saw you wanted help by looking at today's IRC log, and I gather you're going through a gforth tutorial on file handling, but that's all I saw in the log. 09:34:49 Do you still need help? 10:09:05 yeah i tried a bunch of different things to get file appending working but i can't figure it out 10:09:26 all of my experience is with higher level languages so forth is pretty overwhelming 10:10:02 Tony_Sidaway: 10:10:16 learning, did you successfully read and copy files? 10:10:49 i figured out how to write a string to a file and how to create a file if one doesn't exist 10:11:31 i didn't go through the tutorial. i just used it as a reference to try to figure things out 10:12:25 Appending usually means basically producing a new file then deleting the file to be appended and moving/renaming the new one. 10:13:08 are you suggesting i read the file, copy it to a string, append the string, and then write a new file? 10:13:14 I recommend that you follow the tutorial until you encounter a problem. 10:14:19 i assume there is a more direct way of writing at the end of the file. i just can't figure out the forth api and there's no examples online of simple file appending 10:14:32 learning, apoending is basically like copying a file, only you keep the output open and add stuff to it. 10:15:40 someone mentioned in an email chain that its possible to use reposition-file and file-size to write to the end of the file 10:15:50 i just can't figure out how to use them with write-file 10:16:10 i can call reposition-file but i dont know what it actually does 10:17:46 s" filename" r/w open-file drop dup file-size drop rot reposition-file 10:17:51 i do that 10:18:11 but then i cant figure out how to write to the file afterwards 10:18:30 supposedly this repositions the file so that when i write to the file it should be writing at the end of the file 10:18:44 but if i call write-file it doesn't do anything 10:18:52 In C you can open a file to append, position the file pointer at the end, then write more data. I think the problem is that this isn't (officially) supported by the words as defined in gforth. 10:19:23 oh ok. so i've been on a wild goose chase lol 10:19:39 im better off just slurping the file and the rewriting it i guess 10:20:14 thank you for clarifying. its really hard to get help for forth, but i think i could benefit a lot from learning it 10:20:21 learning, I think that's how it's done nowadays. 10:20:30 --- join: jsoft joined #forth 10:20:55 most of my projects are 1 man projects and find myself wanting to have control over everything in my software as well as getting a lot better when i learn how things work under the surface 10:21:41 like i was doing a simple application in python and i found myself having to write a bunch of code just to import everything between files 10:22:34 i think i'd be a lot happier if i could learn something like forth where i have more control 10:22:42 learning, there are people who chat here regularly, who have similar needs and have years (decades, some of them) is experience using Forth to tackle difficult but small problems. 10:23:48 Also it seems to be a rite of passage that everybody at one time or another writes their own forth system. 10:24:28 Strangely enough, the 10:25:06 world isn't full of really brilliant forth systems (though there are many) 10:26:06 i like the power of lisp, but common lisp is too complicated for a single person to understand everything 10:26:29 But writing your own forth is very easy and it's a great way to learn how to program well. 10:27:13 a full system or just a basic repl? 10:28:20 learning, I'm basically a lisper (a schemer, actually) but it's very difficult to write Lisp for the kinds of system I choose to work with nowadays. 10:29:21 i've heard that it's easier to build your own forth than your own scheme 10:29:36 for something that's usable that is 10:30:15 learning, if you study forth at the level of the architecture, there's not much more to it than writing a repl that will accept forth words. 10:30:48 i really think my biggest barrier to forth is doing the most basic things 10:31:14 file managament, string manipulation, etc 10:33:28 gforth is a good way to approach Forth if you already know your way around code in other languages. 10:33:52 It softens the blow. 10:37:10 The developers really know their stuff, and they've spent decades making gforth into a very credible system for Forth coding on modern operating systems. 10:38:14 This isn't really where Forth works best, though. 10:42:04 There are so many competitors, and Forth's biggest weakness is that it's simple . Once you have added the capability to call arbitrary C functions, for instance, you've moved into a software ecology that has many sophisticated alternatives. 10:46:04 --- quit: Tony_Sidaway (Read error: Connection reset by peer) 10:50:11 The problem I run into is that a lot of the programming languages that have the most information avalliable are designed in a very restricting way, and are designed with large development teams in mind 10:51:29 C# for example was my first language, and while there may be some amazing libraries out there for C#, and while it may be very good for writing code that needs to be used in a large organization, it creates a lot of unnessary work, both in boilerplate and in mental gymnastics, that only gets in the way of getting things done 10:51:31 --- join: Tony_Sidaway joined #forth 10:52:07 Sorry, walked out of range of the WiFi. May have missed something. 10:54:06 im hoping that by figuring out how to build a GUI, i'll be able to move forward more with my forth programming 10:54:50 right now im making a wrapper for Tcl/Tk. i dont really know what im doing 10:56:23 i figured out how to call shell commands from forth, so i can create a Tcl shell. but i dont know how to send commands to the Tcl shell from forth. so my plan right now is to write a Tcl program that automatically checks a file and reads in the latest commands. then have gforth write the commands to that file. thats why i wanted to figure out file appending. 10:56:46 learning, Tk is a popular choice. 10:57:01 See https://github.com/wejgaard/TclForth/wiki/GUI-Toolkit-Tk 10:57:18 i just figured it would be easy since i dont know how to do graphics programming and i figured i could use the shell somehow to do it 10:57:43 i saw that but i dont even know what it is 10:57:50 it's its own programming language right? 10:57:51 Thing is, it's very easy to write a Forth on top of Tcl. 10:58:09 but why 10:58:19 i wouldn't be getting a full featured forth right 10:59:05 would it be more normal to work in Tcl with an embedded forth console 10:59:14 than to call Tcl from an external forth 11:01:04 There are complete and entire Forth systems implemented in Tcl. See for instance RiscyPygness. 11:03:20 In the example I linked to, it's a system that uses Tcl to create and manipulate Tk objects. The Forth coffee can then use the Tcl procedures a Forth words. It's a very powerful symbiosis between two different programming systems. 11:03:52 --- quit: learning (Remote host closed the connection) 11:04:04 s/coffee/code/ 11:07:58 You can use other GUI toolkits. For instance you could use gtk (basis of Gnome) or one of its competitors. It depends on what you want, though. 11:09:00 Tk is nice and simple. It's ugly to look at but it works. 11:11:22 I don't want to spend the rest of my life worrying about the kerning in a message box, so I scrupulously avoid aesthetics in user interface design. 11:14:41 --- join: jedb__ joined #forth 11:17:39 --- quit: jedb_ (Ping timeout: 268 seconds) 12:08:06 --- quit: jsoft (Ping timeout: 260 seconds) 12:53:32 --- quit: Tony_Sidaway (Quit: Tony_Sidaway) 12:59:24 --- quit: X-Scale (Ping timeout: 268 seconds) 13:26:23 --- quit: gravicappa (Ping timeout: 265 seconds) 13:37:31 --- join: X-Scale joined #forth 15:48:17 --- quit: ryke (Ping timeout: 258 seconds) 16:03:03 --- join: jedb_ joined #forth 16:06:06 --- quit: jedb__ (Ping timeout: 260 seconds) 16:13:10 --- join: smokeink joined #forth 16:28:00 --- join: dave0 joined #forth 16:38:57 --- join: learning joined #forth 16:45:46 --- quit: learning (Remote host closed the connection) 16:55:10 --- join: learning joined #forth 17:00:11 --- quit: learning (Remote host closed the connection) 17:01:24 --- join: learning joined #forth 17:06:10 --- quit: learning (Remote host closed the connection) 17:07:06 --- join: learning joined #forth 18:18:24 s" third" s" z" append-to-file 18:18:27 got that working 18:33:57 --- join: jsoft joined #forth 18:38:05 --- nick: jedb_ -> jedb 18:44:13 --- quit: jedb (Quit: Leaving) 18:54:36 --- quit: learning (Ping timeout: 268 seconds) 18:58:41 --- quit: dddddd (Remote host closed the connection) 19:03:37 --- join: [1]MrMobius joined #forth 19:13:43 --- quit: MrMobius () 19:13:43 --- nick: [1]MrMobius -> MrMobius 19:17:00 --- join: jedb joined #forth 19:22:15 so I was thinking more about how to make a forth that uses as many registers as possible. what do you guys think if the compiler warned you when it determined that different code paths could leave different numbers of words on the stack preventing optimization? 19:22:32 *number of values 19:24:11 --- quit: dave0 (Quit: dave's not here) 19:40:30 MrMobius, so youre worried about premature optimization? 19:41:55 no I mean if you wrote code that worked fine but left a variable number of arguments, the optimizer would have to copy the registers to the stack which slows everything down 19:42:19 if it warned you, you could ignore it or go back and rewrite it if you want it to be fast 19:43:52 MrMobius, that is way above my pay grade, sorry I'm just a Forth user who knows almost nothing about the inner workings of Forth 19:45:10 I use Mecrisp-Stellaris Forth to make gear, I make the pcb's the wiring, enclosure, everything because Im a electronics tech who does minimal programming 19:45:30 well, if you wrote for example : foo DUPE IF 4 THEN 5 ; then foo may leave 1 argument or 2 arguments on the stack 19:45:48 MrMobius, but youre in the right place here, most members are programmers who have made their own Forth 19:46:10 would it be useful to have the compiler tell you that the word will therefore be slow so go back and make sure it either always leaves 1 or always leaves 2 if you want it to be fast or would that be just useless/annoying? 19:46:12 yes, I follow 19:46:50 I'm guessing the Forth programmer does a lot of the optimisation in the source 19:47:13 tpbsd, right youve mentioned before that youre more of a technician. I was just asking from an opinion point of view. that might be annoying to some people 19:47:56 oh I love offering my informed opinion but if I have no clue, I'll always say so and keep my mouth shut 19:48:25 this ch is a great place to ask questions like that 19:49:03 in mecrisp for example the optimization on the assembly level is all done internally. if you dont understand how that all works you wont know that leaving a variable number of values slows things down. I was just thinking about letting the user know so they had the option 19:49:08 but avtive members seem less than usual right now, I'm guessing xmas holidays etc ? 19:49:17 whereas in mecrisp, your code will just be slower and you wont know why 19:49:40 probably! 19:49:51 the days after xmas are a good time to work on your projects :P 19:50:43 if I think I may have a speed issue I can (and do) check my word with 'see' 19:51:55 but this is my problem, everytime I think I know a way to improve the generated assembly when I check it, I *always* find that Mecrisp-Stellaris has already performed that opt 19:52:50 speed is always the last of my issues tho as I usually work in the electro mechanical world where even micropython would seem lightning fast 19:53:37 if Im looking at efficiency or code size, it's always academic, but Forth does engender a lust for efficiency I have found 19:53:38 ya makes sense. there is a good argument to be made for development speed vs execution speed 19:54:03 MrMobius, for me, development speed is *everything* 19:54:26 the thing is, for a given word, mecrisp may produce assembly that you cant improve on but mecrisp may produce much faster assembly if you write the word slightly differently 19:54:34 execution speed hasnt been a problem for me ever, even when I was using 1Mhz CPU's 19:54:39 which is probably not apparent from using see to look at the assembly 19:55:03 you raise very interesting questions 19:55:23 right. probably not worth the brain power if its fast enough for you already 19:55:41 I'm a great example of crap code, but Forth seems to beat me into sumbission 19:55:58 when I write crap code, it *looks* like crap 19:56:16 Forth seems to magnify the quality of my code 19:56:28 crap code looks *really horrible* 19:56:28 probably doesnt matter as long as it does what you want :P 19:56:41 and you arent imposing it on others 19:56:55 maybe with C, but Forth seems to resent crap code 19:57:35 I refine and refine until the code looks smooth and slick, and at that point there usually isnt I can find wrong with the assembly listing 19:57:44 anything 19:58:04 when Forth source looks right, it always is (for me) 19:59:08 the whole process of machine design from hardware to software is very Zen imho 20:00:38 MrMobius, my Forth source has to work *and* look right, or I'm not happy with it 20:07:30 tpbsd, do you ever notice it copying registers to the stack when you look at the assembly? 20:07:51 you might already be writing code that is easy to optimize 20:08:25 MrMobius, Mecrisp-Stellaris "RA" does a lot with registers 20:09:09 and Matthias (the creator) said that using registers made optimisation possible 20:10:22 for instance the "i" loop counter is a register 20:33:24 --- join: ryke joined #forth 21:06:46 --- join: rdrop-exit joined #forth 21:09:57 Hello Forthslingers 21:14:53 howdy 21:15:55 Hi MrMobius 21:24:21 hey guys 21:24:41 hi tabemann 21:27:14 rdrop-exit: do you have any idea of how Forths that write to flash handle words like IMMEDIATE 21:27:35 like I was thinking IMMEDIATE would have to be placed inside a word 21:28:07 but mecrisp-stellaris apparently has IMMEDIATE after a word definition 21:28:47 --- join: gravicappa joined #forth 21:34:42 One way is to have ;immediate instead of ; immediate 21:36:09 Another, is to have a separate word for "commiting" to flash 21:37:07 Another is to use an umbilical 21:39:32 I'll use ;immediate because it fits better with how I have implemented things so far 21:40:11 The problem with ;immediate is what if you have other header bits not just immediate 21:40:21 currently the code commits data to flash as it is written; when all the bytes in a block have been set, it commits the block 21:40:29 that's true 21:40:37 I might want a compile-only flag as well 21:41:18 Another is to have compiler directives for the flags 21:41:29 so it might be better to put the immediate/compile-only inside the word definition 21:42:25 Call them something like immediate, compile-only, instead of plain immediate 21:42:48 or +immediate -interpretation 21:43:57 IIRC there are some forths which allow placing immediate within a colon definition 21:44:41 That's usually done by words that defini other words 21:44:47 * define 21:45:23 The immediate is meant to act on the child word, it's not a directive 21:45:32 yeah, that's true 21:46:03 immediate isn't normally itself an "immediate" word 21:46:44 My preference is to have an explicit word to commit to flash 21:47:05 probably the best approach then is like ;immediate ;compile-only ;immediate-compile-only 21:47:16 the problem with that is that I've got limited buffer space 21:47:39 any amount of space allocated to buffering data to be written to flash takes RAM away from anything else 21:48:13 how I've got it implemented minimizes the amount of buffer space needed 21:48:25 That's one of many reasons I prefer to go tethered 21:49:25 You could call them [immediate] [compile-only] etc... makes it obvious they are directives that are used within the word 21:50:03 yeah, that'd work 21:54:17 I prefer that to the ;immediate-compile-only combinatorial explosion 21:55:21 yeah, I agree that's not ideal by any means 21:58:54 The [immediate] approach allows you to keep regular immediate for words that define child words 22:00:04 Another approach is to use [ immediate compile-only ] 22:01:00 You just have to make sure that your immediate (and similar words) can work on a word that's still under construction 22:01:53 The advantage of this last approach is you don't need anything new (except the above caveat) 22:02:39 So for example: 22:02:56 : foo ( -- ) .... ; immediate 22:03:00 would become 22:03:20 : foo ( -- ) [ immediate ] .... ; 22:03:30 or 22:03:44 : foo ( -- ) ... [ immediate ] ; 22:04:13 I'm going with both [immediate] and immediate 22:04:27 [immediate] for cases like these, and immediate for words that build words 22:04:43 of course [ immediate ] would work as well 22:05:44 Ok, just make sure it works on the word under construction as opposed to the last defined word 22:08:44 You might want to research how other Forths approach it, it's not an issue that's encountered in a tethered context, so it's not something I've given any real thought to. 22:10:10 There goes that tethered thingy again 22:10:18 lol 22:10:22 Weee! :) 22:11:51 I'm pretty sure my [immediate] and immediate work correctly, the only consideration is that they must come before the end of a colon definition 22:16:00 depends, in some Forths IMMEDIATE uses LATEST which is the last "completed" definition 22:16:49 wait, LATEST is the last "completed" definition? 22:17:02 it depends on the approach that's used for "smudging" (i.e. cancelling) definitions 22:17:09 I've been treating it as the last defined definition 22:18:08 Well, do you consider a definition that's still under construction "defined"? 22:18:47 Different Forths deal with that in various ways 22:19:04 I mean the last one started 22:19:21 The definition is defined as being under construction 22:19:28 surely 22:19:39 What if an exception is thrown before you've finished it? 22:19:58 rdrop-exit: you don't set visible till you're done 22:20:41 but consider the implementation of words such as RECURSE 22:21:06 I don't use a visible bit 22:21:25 Seems a waste 22:21:49 or do you mean something else? 22:22:25 even if you just use eight bits for flags, the main flags I can see are visible, immediate, compile-only, and inline, which leaves four bits over 22:22:38 Why do you need visible? 22:22:49 Why do you need inline? 22:23:15 ... bit, I mean 22:23:27 rdrop-exit: so that if something goes wrong during definition, the malformed definition can't be seen by the outside world 22:24:20 It can't be seen until you link it in to the dictionary 22:24:36 Don't link it in to the dictionary until it's ready 22:24:53 That's what I use REVEAL for 22:25:06 (it's a factor of ";") 22:25:44 : reveal () upcoming dup latest a! current a@ a! ; 22:27:19 oh there is a reason - when finding the last word in the flash dictionary, I need some means of telling me whether the last word is valid 22:27:54 because it searches backwards in the flash for the last written-to block 22:28:28 LATEST holds the address of the last valid word 22:28:36 this is flash! 22:28:52 I can't have repeatedly written-to variables in flash 22:30:11 you can chain it 22:30:47 at the end of each word I write to flash, I write the address of the start of the word 22:31:34 so that it can discover the start of the last word in flash 22:31:57 anyways, I should get to bed 22:32:29 goodnight tabemann 22:33:32 g'night 22:51:54 --- quit: rdrop-exit (Quit: Lost terminal) 22:59:00 --- quit: smokeink (Remote host closed the connection) 22:59:41 --- join: smokeink joined #forth 23:03:35 jsoft, it's only Monday, how come you're sober already ? 23:59:59 --- log: ended forth/19.12.29