00:00:00 --- log: started forth/20.12.04 00:05:56 i wonder how the Forthers fared with day 4 00:06:10 I used parser combinators, other people used regexes 00:59:09 --- join: xek_ joined #forth 01:11:24 I don't bother with AoC, this year I plan on doing some in Forth 01:11:44 Regex's are overrated imo 01:16:45 Last night I was writing 2's solution, trying to do it a bit more 'idiomatically' for neuro_sys, will look at it again at lunch probably 01:16:53 As an exercise and in case it's helpful 01:18:02 Well 2 part 1 anyway 02:31:35 It would be helpful veltas. 02:32:10 I think your code is good, but it's definitely not very "forthy", and so the example might help you 02:32:20 I don't think there is anything objectively wrong with yours 02:32:34 When I put mine in here hopefully some older forthers will flame it and make it even better 02:32:44 siraben: I would imagin that custom parsers were quite common. 02:33:24 I think I strongly dislike 'declarative' code features that hide weeds and complexities that reappear elsewhere 02:33:37 I would be curious to know about the more common styles. 02:33:48 I'm no authority but I will give it a shot 02:34:35 crc's retro forth style is very appealing and something I'd like to get into eventually, but I need to study some more functional programming. 02:34:51 OTOH, I'm curious about the olden times Forth style too 02:36:35 crc's retro is not functional imo, I think it's just factored and higher level than what most forths provide 02:37:03 I think if you want you should just try using it and crc might help, or someone else might help, if things go wrong 02:37:08 * veltas back to work 02:38:17 I might be mixing up terminology, but I'm mostly referring to "combinatory logic", curries and such. Not sure specifically FP (which I'm familiar with the basics, and write such code at work). 02:41:47 Just my opinion that a language is not 'functional' just because it has lots of functions 02:47:33 --- join: hosewiejacke joined #forth 02:48:05 My understanding of the basic requirement is that functions are lambda functions (no free variables) and avoiding mutable state. 02:49:21 --- quit: X-Scale (Ping timeout: 260 seconds) 02:51:00 --- join: X-Scale` joined #forth 03:00:12 neuro_sys, that's close enough to be practical for most all discussions. 03:10:43 Yeah crc's code is not functional but procedural. 03:14:53 AoC is great fun, if anyone here is going it in Forth you could add your solutions to https://github.com/Bogdanp/awesome-advent-of-code 03:36:15 Nice, I might do that 04:32:55 --- quit: jsoft (Quit: Leaving) 04:37:02 --- join: Gromboli joined #forth 05:44:06 --- nick: X-Scale` -> X-Scale 05:50:12 --- quit: hosewiejacke (Ping timeout: 265 seconds) 05:54:34 --- join: hosewiejacke joined #forth 06:36:03 Okay I've written something in lunch break, will test tonight 06:39:54 --- quit: Zarutian_HTC (Remote host closed the connection) 07:08:58 a quick solution in retro for aoc, day 4: http://forth.works/examples/advent-of-code-2020-day-4.retro.html 07:35:38 --- quit: gravicappa (Ping timeout: 240 seconds) 08:02:01 --- quit: hosewiejacke (Ping timeout: 260 seconds) 08:13:11 --- join: gravicappa joined #forth 08:30:48 --- join: hosewiejacke joined #forth 09:29:24 --- quit: dave0 (Quit: dave's not here) 10:04:31 --- join: [1]MrMobius joined #forth 10:06:51 --- quit: MrMobius (Ping timeout: 260 seconds) 10:06:51 --- nick: [1]MrMobius -> MrMobius 12:04:35 --- join: Zarutian_HTC joined #forth 12:04:57 --- quit: gravicappa (Ping timeout: 256 seconds) 12:14:54 --- quit: Zarutian_HTC (Read error: No route to host) 12:15:01 --- join: Zarutian_HTC joined #forth 12:31:24 neuro_sys: There you go https://pastebin.com/raw/NuqnMcuP 12:31:37 Also would be interested in your feedback or anyone's 12:32:38 My attempt at a more 'idiomatic' forth solution to advent of code 2020 2 part 1 13:01:38 veltas: That looks great, I'll study. 13:02:02 It indeed looks like how I imagine it's supposed to be written. I'll try to understand this. 13:16:04 I did day 4 but it was very clumsy. 13:24:49 https://github.com/neuro-sys/advent-of-code-2020/blob/main/day4-2.fs 13:42:39 neuro_sys: I haven't done day 4 yet, but looking at the big OR expression... you could represent each field as a flag 13:43:17 Then check that the result is equal to $FE or $FF (or you know, whatever the result will be with/without the country ID) 13:47:50 c-alpha? isn't used so I can delete that 13:48:10 I think I was using that and then factored it out 13:54:01 The way I wrote so far is just applying c-like language style into Forth I think, and the two things that were problematic are: short-circuit evaluation, and early return/exits. 13:54:58 So perhaps I may stop solving AoC further, and study some more classic Forth code instead (or I'll just keep going, let's see). 13:55:38 You should try writing the first aoc again and see how much you can factor it 13:56:06 And then post it here and we'll see what we can do to take it further 13:56:27 I need write first AoC again indeed, I haven't put it on the github. 13:57:00 I wrote very similar code using locals etc to get c-like code at first, and I think like that it's just C but worse 13:57:25 It's when you take off the training wheels and try and write it more classically that you start to appreciate the elegance of forth, if there is such a thing 13:58:43 The last line I wrote when working on the program was the valid-entry? definition, and I love how simple it turned out at the end 13:59:05 It's just : valid-entry? read-rule remaining-pad ccount rot rot within ; 13:59:29 Like "get the rule, then count how many of the rule's character is in remaining pad space, and check it's within the rule's range" 14:00:31 It reminds me of the examples in Starting Forth near the beginning, like : WASHER WASH SPIN RINSE SPIN ; 14:01:32 But yes, try without locals, and try writing mostly one-line definitions and see what you get 14:02:00 I'll practice that. 14:11:23 crc: Just checked your solution for day 4, looks very good. Very concise and compact. 14:11:55 I see that you use ' to represent strings, but what if they contain whitespace? 14:14:49 Yes, underscores are converted to spaces by default 14:14:52 http://forth.works/chapters/techniques/strings.html 14:18:15 Is there garbage collection in Retro? 14:20:16 not generally. strings at interpret time are allocated from a rotating pool, and memory at `here` can be reclaimed with a little trick 14:21:34 (e.g., as a lot of things allocate space at `here`, if you don't need to keep them after execution is done, you could wrap the code in a `&Heap [ ... ] v:preserve`, which restores `Heap` (the `here` pointer) after the quote finishes running 14:22:38 That sounds quite interesting 14:23:47 full garbage collection is difficult to get working reliably (I explored this in a couple of other languages I've implemented, but haven't missed it enough to go through the trouble of adding to retro) 14:25:24 If I understand correctly `here` points to Dictionary in Forth, and ALLOCATE uses a separate storage than the dictionary data space. Is it similar in Forth? In that case does Retro allocate only in Dictionary and/or on the heap via ALLOCATE? 14:25:43 s/similar in Forth/similar in Retro/ 14:26:14 I have no heap, just what forth calls the dictionary 14:26:38 That's interesting! I assumed retro uses heap a lot! 14:26:41 memory is a fixed pool, allocated at startup and initialized to zero 14:27:04 Just from looking at the code it seemed like that, puts retro in a new light the next time I read it 14:28:03 So far I only used ALLOCATE for reserving space in Forth, and I'm not yet quite sure about how the Dictionary can be utilized for temporary data storage. 14:28:33 I've seen in Retro (and other Forth code) HERE being used in conjuction with CREATE, or right after word definition. 14:36:52 you just need to be careful. if you allocate space at here, then define something you want to keep, you can't reclaim the space. but if you reset the pointers first, it's fine. 14:40:04 crc, the only way i have been able to figure out garbage collection is tokenizing words then marking all data with a type to figure out which ones are pointers 14:40:07 hmm... I have written an object system with gc in Forth. I wonder if a colon def of a word could just be all references. Hmm 14:41:08 MrMobious: not heard of two section object struct implementation then? 14:41:58 I havent. tell me 14:42:36 basically each obj is a header (sizes and gc colour), references section, and data section 14:43:23 (also in header is a bit to tell if this is a broken heart (moved obj) or not) 14:44:57 Can you have an owner of a broken heart 14:45:22 I am mainly using this object system for graphics stuff. Each obj has an xt of its invocation handler. When invoked the handler sees a pointer to the object on TOS 14:46:24 veltas: not sure what you mean. It is basically a record that points to where the object has moved to 14:47:32 * inode counts the yes references 14:48:18 the gc is a modified variant of two space copying collector, only there is just one circular space 14:49:04 easy because all pointer calculations is done via ptr+ word 14:52:11 to diffrientate between old objects and moved ones, I use gc colour bit. The current gc colour flips at each gc run. 14:54:50 I have even sketched out a way to do 'ref gone linear' detection and notification but that is more complex than I am currently using this for 14:59:19 but using this for Forth words? well that might be tricky 15:02:28 --- quit: xek_ (Ping timeout: 256 seconds) 15:43:32 veltas: I looked at your code, it's a very good example of the classic style I'd like to learn more. 16:24:41 I'm puzzled by the lack of visibility about Forth on the internet. 16:25:54 I think the first thing that got me interested in Forth was an episode of Computer Chronicles where Elizabeth Rather was a guest. And later the video on YouTube by Samuel Falvo. 16:35:47 --- quit: arrdem (Quit: Connection closed for inactivity) 16:36:54 https://www.youtube.com/watch?v=81bkIqPpe0g 18:15:17 --- join: boru` joined #forth 18:15:19 --- quit: boru (Disconnected by services) 18:15:22 --- nick: boru` -> boru 19:09:17 --- quit: Zarutian_HTC (Remote host closed the connection) 19:13:41 --- quit: pointfree (*.net *.split) 19:13:41 --- quit: heredoc (*.net *.split) 19:13:58 --- join: heredoc joined #forth 19:19:04 --- join: pointfree joined #forth 20:03:50 --- join: jsoft joined #forth 20:46:47 --- quit: sts-q (Ping timeout: 264 seconds) 20:48:21 --- quit: Gromboli (Read error: Connection reset by peer) 20:49:31 --- join: sts-q joined #forth 20:51:21 ^ chuck moore on colorforth. a fun surprise, but i'd also love a link to sam's video, neuro_sys 20:55:58 Lisp lead to me Forth, heh. 21:09:11 --- join: gravicappa joined #forth 23:20:25 --- quit: proteusguy (Ping timeout: 256 seconds) 23:21:44 --- join: proteusguy joined #forth 23:59:59 --- log: ended forth/20.12.04