00:00:00 --- log: started forth/19.05.09 00:46:22 --- quit: X-Scale (Quit: HydraIRC -> http://www.hydrairc.com <- \o/) 01:13:23 Rickta59: what was your snipped that expired? 01:47:33 --- join: dddddd (~dddddd@unaffiliated/dddddd) joined #forth 04:53:48 --- quit: Croran (Ping timeout: 252 seconds) 05:00:01 --- quit: pierpal (Quit: Poof) 05:00:10 --- join: Croran (~quassel@2601:601:1801:6dde:642f:8c7f:686e:2ece) joined #forth 05:00:19 --- join: pierpal (~pierpal@host57-236-dynamic.22-79-r.retail.telecomitalia.it) joined #forth 05:41:49 --- join: andrei-n (~andrei-n@189.0-240-81.adsl-dyn.isp.belgacom.be) joined #forth 05:43:55 Hello. I would like to make a Turbo Vision-like application using GForth. So I have found that it's possible to write event-driven programs in GForth: https://bernd-paysan.de/gforth-manual/Pthreads.html Also it's possible to write TUI (if I'm not mistaken). The only thing that's missing is the mouse. How can I get access to the mouse events? Thanks. 06:03:32 I'm not a Gforth user, but I assume your choices are either through terminal input via KEY/EKEY, or some external C library. 06:13:10 On Unix the ncurses C library is probably the most common choice for TUIs 06:23:11 If you're coding to a specific terminal or terminal emulator you need to find out the escape codes corresponding to mouse events. 06:27:24 rdrop-exit, Is there an ncurses library for GForth? 06:29:35 andrei-n: I've got some mouse event capturing code here https://hub.darcs.net/pointfree/forth-sixel/browse/paint.4th#37 06:30:45 https://hub.darcs.net/pointfree/forth-sixel/raw-file/docs/all-escapes.txt has more documentation 06:30:54 ncurses is a C library, I assume you can access it via GForth's C interface 06:32:22 https://en.wikipedia.org/wiki/Ncurses 06:34:49 pointfree, rdrop-exit thanks a lot 06:35:02 np good luck 06:35:20 :) 06:41:15 --- quit: dave0 (Quit: dave's not here) 06:43:39 WilhelmVonWeiner: I think it was just the mhz.fs i posted 06:49:54 well John said it was how he'd do it 06:50:28 so I thought I'd take a look because he and I approach Forth quite differently 06:50:32 but it expired 06:54:23 WilhelmVonWeiner: https://raw.githubusercontent.com/RickKimball/mecrisp-stellaris/nucelo-f030r8/mecrisp-stellaris-source/stm32f030r8-ra/mhz.fs 06:54:54 the MHz word and the use of the stack with the case 06:56:32 --- join: X-Scale (~ARM@71.40.54.77.rev.vodafone.pt) joined #forth 07:02:01 --- join: proteusguy (~proteusgu@cm-58-10-154-216.revip7.asianet.co.th) joined #forth 07:02:01 --- mode: ChanServ set +v proteusguy 07:09:52 %10000 over 48 = if 1+ then FLASH_ACR ! 07:10:03 can replace your first case statement 07:12:54 you could use "48 = negate +" 07:13:11 oh yeah 07:14:13 or even "48 = negate or" 07:14:24 my solution to removing the `if` would've been 48 / + which wouldn't work for numbers over 95 07:15:36 at this point i'm trying to be readable i realize there is lots of opportunity for optimization 07:16:06 my real question was about dealing with stack variables you use multiple times in function 07:16:27 dup case seems reasonable 07:17:12 ok and that is what the OP meant when he said that is how he would do it 07:17:42 I don't think `%10000 over 48 negate + FLASH_ACR ! \ set PRFTBE if 48MHz, unset elsewise` is unreadable 07:18:24 i'm on day 7 of my forth exploration :) 07:18:29 it is all unreadable 07:18:54 Rickta59, you're not supposed to read it, you're supposed to write it. It's a write-only language. ;-) 07:18:55 I would look at your comments and try to derive names for refactoring the code 07:19:26 proteusguy, +1 07:20:25 when i'm writing it makes sense ... the next day .. not so much 07:21:13 : sset ( bank bit) lshift swap bis! ; 07:21:22 That's because you have a 40 line definition 07:21:37 : cset ( bank byte) lshift swap bic! ; 07:22:09 so the key is may words all doing something simple rdrop-exit ? 07:22:15 is make 07:22:29 yes 07:22:32 exactly that 07:22:39 Yes, 1-3 lines long preferably 07:22:48 Rickta59, I'm only partly joking. It's something that takes a while for your head to change the way it reads the code. It'll come together quickly but you definitely have to be ruthless at refactoring and eliminating complexity. 07:22:59 Double that for loops 07:23:15 do you use mcu or desktop forth rdrop-exit ? 07:23:21 yes, reading Forth is a learned skill 07:24:03 Both, host forth and target forth 07:24:10 do you use stm32 chips? 07:24:14 no 07:24:18 which ones? 07:25:38 flipping the clock speed is a pain in the ass as your only interface is the serial port which depends on the SYSCLK 07:25:40 I'm looking at PIC32, but I don't have a next project in mind 07:26:11 mess it up and you have to go back to reset 07:26:37 so i basically cloned my c code in forth 07:26:58 for each line of c reverse it and write it out and call it forth 07:28:03 were the cases switch statements in c 07:28:25 actually it a c++ and it is all in templates that get rid of the case 07:28:26 A rule of thumb is that most times when you need a line comment, you should be factoring out a word 07:28:30 MHz<24> ... 07:29:05 i commented so i would remember what it did but yes i should probably change that 07:29:25 sorry <24>MHz 07:30:15 all this stuff becomes constants in c/c++ 07:30:41 in the c++ template there is a case but it all goes away at compile time 07:31:05 * c++ without any stdlib or c++ lib 07:31:13 --- quit: travisb (Ping timeout: 248 seconds) 07:31:14 I've never used a case statement in Forth 07:31:39 does a case statement exit on a match or continue executing 07:31:48 or execute the fallthrough case 07:32:05 seems to exit based on what it is doing 07:32:38 can't believe CASE is actually a standard word 07:32:52 are you new to forth also WilhelmVonWeiner ? 07:33:01 nope 07:33:11 ENDOF (6.2.1343): "Mark the end of the OF ... ENDOF part of the CASE structure. The next location for a transfer of control resolves the reference given by of-sys. Append the run-time semantics given below to the current definition. Replace case-sys1 with case-sys2 on the control-flow stack, to be resolved by ENDCASE." 07:33:22 well over a year of Forth lifestyle now 07:33:41 I love it and want to nourish it with attention and feed it like a baby bird 07:34:51 Look to your comments, make words such as +foo to enable foo, -foo to disable foo, etc... 07:35:06 is that a standard naming thing? 07:35:08 +foo? 07:35:27 It's common practice 07:35:54 : set ( port bit) ; and : unset ( port bit) ; imo but still +x -x are cool and all 07:36:04 but not universal 07:36:08 set and unset feel very desktop c++ 07:36:09 just a lot of consts for a + and - 07:36:26 something. is a way to print things/ 07:36:28 ? 07:36:53 so whay +foo vs foo+ ? 07:36:58 why 07:37:24 foo+ would be increase or add to foo 07:37:25 doesn't really matter but I would read the latter as incrementing foo 07:37:45 foo^ foov ? 07:38:11 +foo I would read as : +foo ( n - n) foo @ + ; to be fair 07:38:13 Don't go overboard though on the naming conventions 07:38:23 names are a spook 07:38:39 i'm just searching for the right scheme 07:38:48 hsi_en means something to me 07:38:54 mco_en 07:38:54 whatever feels right to you really 07:39:03 master clock out enabled 07:39:43 so you would change that to +mco 07:40:48 can be, you can start out with dashed words and then come up with your preferred abbreviations later 07:41:04 why dashed? 07:41:14 doesn't matter 07:41:24 dashes, underscores, the word GUMP 07:41:25 master-clock-out-enabled 07:41:26 i was just wondering if that is a common forth convention 07:41:53 doesn't the length of the word affect the size of the code 07:42:04 * working with small chips here 07:42:12 depends on the forth? mecrisp... maybe 07:42:21 yes this is all mecrisp 07:42:29 on both cortex-m0/m3 and msp430 07:42:30 It's just that Forth allows dashes, I prefer them to underscores 07:42:35 some forths don't store the whole word but the first 3 chars and the length - polyforth did that 07:42:58 i haven't looked how it does the word lookup 07:42:59 right 07:43:30 i have thousands of constants 07:43:42 that describe the registers 07:43:55 i'm sure i would fill up flash if i used them all 07:44:28 so would you hard code the constants as numerics and then use +mco 07:45:47 or would you define everything as constants 07:46:11 If the constant isn't used anywhere else, then I would just hardcode it into the word that uses it 07:46:19 and comment it/ 07:46:20 ? 07:46:49 If it's used for many words I would make a constant 07:47:11 %1 18 lshift RCC_CR bis! \ set RCC_CR_HSEBYP 07:47:28 No need to make a constant that is used only once 07:47:40 in c that looks like RCC->CR |= RCC_CR_HSEBYP; 07:48:12 so the constant is a mask of 1 << 18 07:48:42 so i just used the hard coded number and didn't create a constant 07:48:49 do you have a better approach for that? 07:49:49 I don't know the Forth your using but in mine I would do: 07:50:40 : +rcc_cr 18 bit rcc_cr set ; 07:51:10 k 07:51:17 I should have put ( -- ) in there 07:51:19 bis! is set 07:51:30 rcc_cr would be what a constant? 07:51:54 an address constant I assume 07:52:01 k so you don't use caps? 07:52:11 i know it is a constant because ITISBIG 07:52:16 I use caps for metacompilation constants 07:52:44 i don't know what metacompilation constants are 07:53:26 why make a word for +rcc_cr if it is only used once? 07:53:37 That's ok, there for making a new forth out of another forth 07:53:38 i'm going to call that once 07:54:09 Rickta59: future readability 07:54:31 rcc_cr is full of flags and configs 07:54:50 Right, I don't normally put headers on targets, so it doesn't cost me anything really 07:55:08 it would be more like +rcc-cr-high-speed-external-bypass 07:55:35 but all it is doing is setting a flag 07:55:56 but it has to be done at the right time in the right order with code required to trigger it 07:56:04 hsi has to be on .. pll has to be off 07:56:23 must be done before setting the HSEON flag 07:56:29 then you have to wait for it to work 07:56:42 which is what mhz is all about 07:57:28 oh and as your changing it you have to make sure you set the uart speed so you can continue to type into forth 07:58:39 i get your point though :) 07:58:43 thanks for the input 07:58:46 "+rcc-cr-high-speed-external-bypass" screams "verbose & crazy" to me 07:59:07 i was just extrapolating what he said 07:59:08 Oh ya, me too 07:59:39 I am not a fan of hyphenated names - people or code. 08:00:01 i thought i had distilled down to the minimum I had thought would make the word 08:00:30 Me neither 08:00:32 The only reason I'd use _ with c names is because C doesn't have "vocabularies", so I stick to object_verb() 08:00:59 All I was saying is if you can't think of an easily decipherable name off the bat, 08:01:25 rdrop-exit: perhaps it means "take a break and rethink the problem" 08:01:38 temporarily use a longer hyphenated word until inspiration comes 08:01:39 ..paging thru Thinking Forth won't hurt 08:01:41 i would make it +rcc_cr_hsebyp if i thought i might use it more than once 08:02:06 but i will never use it except in this context 08:02:09 and once 08:02:21 Rickta59: if you're using it once... probably don't bother 08:02:34 but I can try it and see what the code size difference is 08:02:37 have your +whatever words call an internal set word maybe 08:02:48 PoppaVic: Not in this case, these are names of hardware bits 08:02:50 internal set word .. wha tis that? 08:02:59 also looking at mecrisp, to save space constants are folded automatically 08:03:17 yeah why i also did it .. the constant folding 08:03:19 rdrop-exit: yeah, I got that - I perked up to note the Arm, and I already know the samD's are gonna' make me scream 08:04:23 Rickta59: a word like : set %1 swap lshift swap ! ; 08:04:33 so : +this this 18 set ; 08:04:47 neat thanks 08:06:08 1 swap lshift is normally called either 2** or bit 08:06:20 never knew that 08:06:21 noice 08:06:48 2** when you want to emphasize you're raising 2 to a power 08:07:15 bit when you want emphasize you're creating a mask with the nth bit set 08:07:39 how do you go the rshift way? 08:07:40 ' lshift alias << ' rshift alias >> \ Yes, I'm like that. 08:07:47 yeah that is me too PoppaVic 08:07:52 and I 08:07:54 You can also use "mask" as a synonym for 1- 08:08:11 So you can say get a "3 bit mask" 08:08:40 i.e. % 111 08:09:18 bit vs bis? 08:09:20 Of course you're going to need constant folding if you do such things 08:09:53 "bit" is just a synonym of "2**" 08:10:08 ic 08:10:21 "3 bit" gives you % 1000 08:10:33 "3 bit mask" gives you % 111 08:11:01 it's nicely done, alas - I notice most bitsets/masks are clusterfucks ;-P 08:11:20 most mcu programming is all about setting and getting bits 08:11:39 You can also have "~mask" as a synonym for negate, which gives you an inverted mask from a bit 08:11:50 heh.. I thought it was about hair-tearing and keeping the damned datasgeet open 24/7 ;-P 08:12:14 e.g. "3 bit ~mask" gives you % 11...11000 08:12:34 PoppaVic, and discovering bugs in their hardware 08:12:58 zy]x[yz: and learning they misspelled or changed the damned name between models or sheets 08:13:09 Yikes 08:13:37 when i was in school i remember one class where a lot of us were using a phillips 8051 for some project, and several students were trying to use the builtin spi interface and could never get it to work 08:13:43 i didn't use it, so i didn't have any problem 08:14:02 it was until years later i busted out my old 8051s just to play around, and i tried using it, and found that it just doesn't work 08:14:16 rdrop-exit: dude, seriously: when you get a cascade of #ifdef that renames the version regs/bits to a COMMON name - someone needs to be kicked in the balls. 08:14:24 the last bit of every transaction transitions on the wrong clock transition 08:14:43 zy]x[yz: nice 08:15:37 brief description of it here https://github.com/cmtptr/avr/commit/21f05acfde26808ebddda43fbae5288f94bc16aa 08:16:23 turns out this was after philips was bought out by atmel or whoever bought them, so the product is defunct anyway and there's nobody to report the bug to 08:17:05 RIP 08:26:11 Gotta walk the dogs before bed, good night all, keep on Forthin' 08:26:25 --- quit: rdrop-exit (Quit: Lost terminal) 08:27:13 peace! 08:27:27 peas! 08:33:34 OK, brainfart... I'm thinking of a ring-buf for IO.. I keep thinking ONE is all I need for both in & out: input to HEAD and output from TAIL, but maybe I just need to remember better.. It's a FIFO I am describing, I am sure 08:34:22 you need one for each direction 08:35:33 Damn.. I was afraid of that. Thanks.. Obviously I was conflating memories 09:12:37 so got rid of the case with: 09:12:39 dup 24 > if %10001 else %10000 then FLASH_ACR ! 09:13:21 if else then are unnecessary here though 09:13:37 ok . so ? 09:13:59 works I guess but don't mind me 09:14:01 * WilhelmVonWeiner shrugs 09:14:13 is there a better way? 09:16:11 %10000 over 24 > negate + 09:16:32 dup 24 > negate %10000 + 09:16:56 then you don't even perform `over` :^) 09:18:03 so you don't need the if else then if it is just 2 values? 09:18:07 2 actions 09:20:16 no, no 09:20:20 it's just than 09:20:30 yeah i just tried that it wasn't what i was thinking 09:20:31 *that you don't need the logic for the conditional 09:20:46 the conditional's logic is just bloat in this case 09:24:16 or just dup 24 <= %10001 + 09:28:16 good shout 10:41:02 --- join: dys (~dys@tmo-122-190.customers.d1-online.com) joined #forth 10:47:28 --- quit: pierpal (Quit: Poof) 10:47:45 --- join: pierpal (~pierpal@host57-236-dynamic.22-79-r.retail.telecomitalia.it) joined #forth 11:52:32 --- quit: gravicappa (Ping timeout: 252 seconds) 13:51:07 --- quit: andrei-n (Remote host closed the connection) 13:52:37 Rickta59: Hmm, TRUE doesn't have to be -1 though, just "all bits set". Since most computers use 2's complement it should work out, but it isn't necessarily true for exotic platforms. 13:55:39 --- quit: Zarutian (Read error: Connection reset by peer) 13:55:59 --- join: Zarutian (~zarutian@173-133-17-89.fiber.hringdu.is) joined #forth 14:02:09 I don't think I care about portability I'm just using mecrisp-stellaris forth john_cephalopoda 14:02:41 --- quit: pierpal (Ping timeout: 248 seconds) 14:03:16 Rickta59: It's just a thing from the Forth standard. 14:04:20 do you think the negate version is safer? 14:07:15 Eh, it's more of a fun fact than a real problem. 14:07:29 I doubt that you'll ever run into a platform where this becomes a problem. 15:33:54 --- join: dave0 (~dave0@069.d.003.ncl.iprimus.net.au) joined #forth 15:34:53 hi 16:01:09 --- join: pierpal (~pierpal@host57-236-dynamic.22-79-r.retail.telecomitalia.it) joined #forth 16:10:41 --- quit: john_cephalopoda (Ping timeout: 248 seconds) 16:38:21 --- join: john_cephalopoda (~john@unaffiliated/john-cephalopoda/x-6407167) joined #forth 17:27:22 --- join: travisb (~travisb@h193.235.138.40.static.ip.windstream.net) joined #forth 17:35:28 --- join: rdrop-exit (~markwilli@112.201.166.63) joined #forth 17:38:39 hey 17:38:55 Hi travisb 17:39:25 I'm not sure what to do next with hashforth - should I try porting it to another platform? 17:40:06 (and by another platform I don't mean a large system - i.e. anything with an MMU and which runs a kernel) 17:40:06 john_cephalopoda: "negate +" is just "-" 17:43:18 negate + has a performance hit though 17:44:19 especially if NEGATE isn't a primitive 17:46:40 Right, if no optimizer, better to use - 17:48:15 Actually, regardless, since the intent is pretty obvious anyhow 17:55:10 What is hashforth running on now? 18:00:33 john_cephalopoda: Unless you work for a museum, you're unlikely to run into a non 2's complement machine. 18:03:13 i did negate as 0 swap - 18:04:27 You're machine doesn't have a negate instruction? 18:05:02 it does but i tried to use less primitives 18:05:21 then use "not 1+" 18:06:13 that would work too :-) 18:06:37 ;-) 18:09:05 --- quit: travisb (Ping timeout: 268 seconds) 18:15:25 Good morning, now that I have my coffee c[_] :) 18:16:02 so is half the world of forth in AU? 18:16:13 lol 18:16:32 right about now my eyes are burning from reading forth :) 18:16:37 9pm 18:17:06 it's 11:15am here :-) 18:17:15 i'm drinking tea but in a minute i 18:17:18 'll grab a beer 18:17:29 :) 18:18:10 9:17 am here 18:18:36 (Manila) 18:19:28 has anyone tried j1 on an fpga ? 18:20:48 Not I 18:34:13 --- join: travisb (~travisb@172-13-49-137.lightspeed.milwwi.sbcglobal.net) joined #forth 18:48:11 --- quit: dddddd (Remote host closed the connection) 19:30:33 Brad Eckert just posted a 32-bit portable Forth VM project: 19:30:36 https://groups.google.com/forum/#!topic/comp.lang.forth/r6X8ysbhYyA 19:53:28 that message points to: https://github.com/bradleyeckert/Tiffany 20:37:01 --- join: gravicappa (~gravicapp@h109-187-242-147.dyn.bashtel.ru) joined #forth 21:05:04 --- quit: rdrop-exit (Quit: Lost terminal) 21:11:25 --- quit: pierpal (Quit: Poof) 21:11:44 --- join: pierpal (~pierpal@host57-236-dynamic.22-79-r.retail.telecomitalia.it) joined #forth 22:45:10 --- quit: dave0 (Quit: dave's not here) 22:59:09 --- join: andrei-n (~andrei-n@231.182-64-87.adsl-dyn.isp.belgacom.be) joined #forth 23:01:15 Hello. Is there a forth book with exercises and solutions in order to learn the idiomatic way to code in forth? I have only found "Forth Application Techniques", but there is not a lot of exercises and they are all very short... Thank you. 23:02:20 Starting Forth 23:05:58 PoppaVic, It's the first thing I have read... Perhaps you have examples of good code, so I can reverse-engineer and try to repeat what they did? 23:09:50 No, sorry. TOo many variations to ever do so. I suspect there are ANS-standard things, like that Rosetta-stone stuff.. Gforth is pretty common, but just too damned much variation. 23:10:38 I'd recommend the same thing I've always told folks in ##C: pick a few CLI tools that you can clearly compare against and reimplement them. 23:11:09 ..Not, (of course), panicking over the innumerable command-line-options. 23:12:29 PoppaVic, What do you think about the Software Tools in Pascal book? I plan to follow this book and implement the exercises in Forth. 23:12:34 so, an example is sort(1), or tee(1) or more(1), head(1), tail(1), etc 23:13:07 No idea.. Haven;t used pascal since TP, some... nearly 40 years ago now - more than 30, methinks 23:15:14 See, you might even download the old FIG Forth Dimensions back issues as well - but then you get involved with FIG/F78/F79/F83 and commercial variations of forth 23:19:36 PoppaVic, So, if I understand correctly, everyone invents his own Forth coding style, since there are so few examples nowadays... 23:20:12 Yeah, there are recommendations published multiple places, and Thinking Forth has some of them gathered as well. 23:20:39 I tend to write vertically, just like in C; others tend to write horizontally. 23:21:51 I tend to name simply, deploy vocabularies as I want - to avoid clashes.. I type lowercase, uppercase or camelcase much as I would in C. 23:22:56 Of course, unlike for C or C++, we have no tool like astyle or indent(1) for C. 23:27:04 Yeah, the indentation is not an easy problem. Especially for things like 'else'... Perhaps I should study some code on Github and write some kind of pretty-printing tool. 23:27:30 I doubt it's really doable. 23:27:48 PoppaVic, why? 23:27:56 forth really lacks "keywords" - everything is mutable - everything 23:28:20 You'd need to track from the very core of the implementation at hand 23:40:49 --- quit: dys (Ping timeout: 245 seconds) 23:59:59 --- log: ended forth/19.05.09