2025-12-13 03:53:36 hi KipIngram 2025-12-13 06:21:14 KipIngram: do you end up redoing a lot of stack juggling then? 2025-12-13 06:21:31 like you were processing 4 things in a loop and have to go back and add a 5th 2025-12-13 06:26:17 MrMobius, I find I dont have to as each word is unique when designed, and I never have to go back to it after the embedded project is finished 2025-12-13 06:27:19 if a word needs 5 and not 4 items on the stack, that will all happen within the word design at the time 2025-12-13 06:27:37 I think that works ok for simple things but if there's any complexity, refactoring is a normal part of writing software 2025-12-13 06:27:52 Combining two things you though initially though should be separate or vice versa 2025-12-13 06:31:19 or maybe just rewrite the word rather than modify it 2025-12-13 06:40:21 MrMobius, yeah refactoring is a major interest, but real world enbedded project words are always very simple, especially when short 2025-12-13 06:43:27 for instance this is my thermometer Word that converts counted pulses to degrees C 2025-12-13 06:43:30 : degrees.c? (count -- C ) \ convert lmt01.count to degC, Temp (C) = ((count/4096) *256) -50 2025-12-13 06:43:30 0 swap \ convert numbers to s31.32 and calculate 2025-12-13 06:43:31 0 4096 f/ 2025-12-13 06:43:31 ; 2025-12-13 06:44:03 it's boringly simple, there is no need to make it faster or smaller 2025-12-13 06:44:19 and the output is fixed point 2025-12-13 06:44:48 here it is reading the temp right now: t 32,3 C 90,1 F ok. 2025-12-13 06:44:57 Hello o/ 2025-12-13 06:45:16 hello ghodawalaaman_ 2025-12-13 06:45:24 :D 2025-12-13 06:47:52 MrMobius, I could refactor a lot, but why ? the thermometer is about 1k in a 64k mcu that cost $0.60, the Mecrisp-Stellaris is about 20k, so I still have about 30Kb left that will never get used 2025-12-13 06:48:29 and the 1k is mainly that long because it's a prototype and has a lot of unused stuff in it 2025-12-13 06:48:54 can someone link me to the smallest forth specification? 2025-12-13 06:49:31 I am creating a forth interpreter that's why I am asking... 2025-12-13 06:52:30 MrMobius, it's very unusual for me to need to worry about >2 items on the stack in one word 2025-12-13 07:02:31 ghodawalaaman_: https://github.com/uho/preforth and referenced https://github.com/uho/minimal 2025-12-13 07:04:14 https://ratfactor.com/forth/implementing 2025-12-13 07:05:06 nice, Thanks 2025-12-13 07:05:33 DKordic: maybe I should implement some old specification of forth 2025-12-13 07:05:37 it will be easier IMO 2025-12-13 07:07:22 ghodawalaaman_: I would not recomend that. Start with Dave Gauer's page. 2025-12-13 07:08:16 DKordic: https://ratfactor.com/forth/the_programming_language_that_writes_itself.html 2025-12-13 07:08:18 this one? 2025-12-13 07:09:14 ""Implementing Forth"". That one is inspiring, and it can wait. 2025-12-13 07:09:38 The essence of Forth is composition of functions. Concatenation of machine code is also composition of their functions. 2025-12-13 07:11:47 https://www.waveshare.com/product/raspberry-pi/boards-kits/raspberry-pi-pico-3/rp2350-plus.htm 2025-12-13 07:11:51 https://www.waveshare.com/product/arduino/boards-kits/esp32/esp32-p4-nano.htm 2025-12-13 07:17:12 ghodawalaaman_: def swap(*D, **W): OK(D[1], D[0], *D[2:], **W) 2025-12-13 07:17:45 it's forth? 2025-12-13 07:17:46 :o 2025-12-13 07:18:04 Yes! 2025-12-13 07:18:28 now I think I might not be able to implement all of it 2025-12-13 07:18:29 maybe 2025-12-13 07:18:31 I don't know 2025-12-13 07:20:33 def to(V, *D, **W): W[name()] = V; return OK(*D, **W) 2025-12-13 07:21:10 All of what? 2025-12-13 07:22:19 all of the feature of forth 2025-12-13 07:23:39 I understand You might feel intimidated. IMHO any effort will be well worth it. 2025-12-13 07:24:04 Thanks :) 2025-12-13 07:24:44 What are You seeking? 2025-12-13 07:25:04 W/Cognitive_closure ? 2025-12-13 07:25:18 wdym? 2025-12-13 07:25:57 Why are You interested in implementing Forth? 2025-12-13 07:26:27 because it's really interesting language 2025-12-13 07:26:38 For me it showed that Python and C are far more difficult than it needs to be. 2025-12-13 07:27:10 that's true, it depends which type of programming you like 2025-12-13 07:27:33 btw do I keep the function name case-sesitive or not? 2025-12-13 07:28:31 I don't see that as a question ;) . Case sensitive of course. 2025-12-13 07:28:59 okay okay :D 2025-12-13 07:29:34 so basically now the user of my compiler can define their own DuP or dUP or dup 2025-12-13 07:29:55 only DUP all capital will be the built-in function 2025-12-13 07:30:00 other function will be use defined 2025-12-13 07:30:14 As well as "": 13 17 19 ;"". 2025-12-13 07:30:43 nooo, it will make it harder 2025-12-13 07:31:18 or wait maybe I can do it? 2025-12-13 07:38:07 Even gforth has case-insensitive, as well as case-sensitive, Namespaces. I haven't seen anyone do it... Wouldn't it be clever to make base 10 and 16 number literals their own dictionaries (or how should we call it)? 2025-12-13 07:40:32 ghodawalaaman_: "": swap : ToS [ Literal ] ; : NoS [ Literal ] ; ToS NoS ;""? Would this be a good test for Your (Forth) system? 2025-12-13 07:41:08 yeah, but currenly it only support +,-,*,/ 2025-12-13 07:41:13 and dup and MOD 2025-12-13 07:41:23 I have made is case sensitive 2025-12-13 07:42:22 Are You aware of the idea of ""Maxwell's Equations of Software""? 2025-12-13 07:43:52 https://ibb.co/F4d3Gjk8 2025-12-13 07:44:16 I am making a very very long switch case, it's not ideal no? 2025-12-13 07:44:24 let me googe it 2025-12-13 07:45:17 I wouldn't worry too much about making it ideal of it's your first try :) 2025-12-13 07:45:43 yeah :D 2025-12-13 07:52:07 In Python Variables (local, and nonlocal (including module)) are implemented through chained Hash Tables. 2025-12-13 07:53:20 https://forth-standard.org/standard/core 2025-12-13 07:53:36 if I implement all of core function then my language will be turing complete right? 2025-12-13 07:53:41 From Python FAQ["Where is Switch Statement"]: ""{True: yes, False: no}[test()]()"". 2025-12-13 07:53:58 W/Turing_tarpit 2025-12-13 07:54:17 wdym? 2025-12-13 07:55:02 IMHO Forth "'Standards"" are a waste of time. 2025-12-13 07:55:54 Even R{5,6,7}RS is disappointing. 2025-12-13 07:57:17 umm 2025-12-13 07:57:33 DKordic: can you link me to a specification which is easy to implement? 2025-12-13 08:00:30 also forth gives us the ability to store variable 2025-12-13 08:00:35 I don't know how to handle that case? 2025-12-13 08:01:45 I hope https://youtu.be/ViPNHMSUcog helps for a start. ""The Next 700 Programming Languages""? https://bitsavers.trailing-edge.com/pdf/mit/ai/aim/AIM-453.pdf ? 2025-12-13 08:04:50 By updating Hash Table (or how ever we shall call it)? 2025-12-13 08:06:50 DKordic: yeah but that doesn't look cool, you know what I mean :p 2025-12-13 08:07:22 Sorry, which parts exactly. I might agree. 2025-12-13 08:07:55 I mean, if I show the user/developer 1,2,3 etc integer instead of 0x28943723aa address then they might not like it 2025-12-13 08:09:21 I am not following... Address of what? What are ""1,2,3""? 2025-12-13 08:10:10 if we store the data as HashTable then the key will be 1,2,3 etc instead any random number.... oh wait we can have a random number as key 2025-12-13 08:10:12 hmmm 2025-12-13 08:11:46 Lua is opsessed with HTs. There might be more appropriate DS. 2025-12-13 08:15:10 what do I do 2025-12-13 08:15:13 I am so confused 2025-12-13 08:15:20 HashTable seems like a good idea 2025-12-13 08:15:20 Why? 2025-12-13 08:15:41 what do you suggest? please tell me something 2025-12-13 08:15:51 It is a broad concept. It's special case might as well be linked list. 2025-12-13 08:16:36 hmm, let me think 2025-12-13 08:17:00 Find simple things to begin with. 2025-12-13 08:17:30 can I get address of a list variable in c# 2025-12-13 08:17:40 I lost the link... Challenge is most rewarding whrn it is not far above or bellow one's current competence. 2025-12-13 08:17:58 yeah that's true 2025-12-13 08:18:13 implementing forth is neither above or below my skill level 2025-12-13 08:33:54 DKordic: I just realized something 2025-12-13 08:34:04 the tokenizer function I am using is very naive 2025-12-13 08:34:13 I can't parse ."hello world" 2025-12-13 08:34:16 it will think it like 2025-12-13 08:34:19 ."hello 2025-12-13 08:34:20 world" 2025-12-13 08:43:30 That is why there is whitespace after ." 2025-12-13 08:43:42 And similar words. 2025-12-13 08:51:28 DKordic: okay so I won't need a lexer or anything 2025-12-13 08:51:32 that's cool! 2025-12-13 10:55:54 I am going mad parsing forth lol 2025-12-13 10:55:58 I underestimated it 2025-12-13 11:02:45 what part are you stuck on? 2025-12-13 11:04:59 I think I solved it \o/ 2025-12-13 11:05:09 MrMobius: could you give me a test string to see if it works or not 2025-12-13 11:05:18 I still have to parse function 2025-12-13 11:05:24 1 2 3 swap drop 2025-12-13 11:05:32 okay 2025-12-13 11:05:45 const string code = ".\" aman\n10 10 - . \" 10 \n 10 \n + ."; 2025-12-13 11:05:56 this worked as expected 2025-12-13 11:06:15 MrMobius: I will share the code once it's ready, then we can discuss on the issue 2025-12-13 11:06:22 for now I have created a workaround 2025-12-13 13:23:52 delgnam: welcome to forth o/ 2025-12-13 13:24:14 everyone welcome delgnam, he is new to ##forth language :D 2025-12-13 13:24:31 Hi o/ ghodawalaaman invited me here. 2025-12-13 13:42:48 Welcome. Glad to see that. 2025-12-13 13:43:22 o/ 2025-12-13 13:43:47 \o DKordic , ajhidd2 2025-12-13 13:44:54 ghodawalaaman: I guess You are not familiar with ""mk-counter"" example. It is very elegant. It shows the connection between Objects and Subroutines (hopefully functions). 2025-12-13 13:46:07 yeah, also it's been some time since I last touched forth language 2025-12-13 16:07:07 delgnam: Welcome to Forth and to ##forth. Hope you enjoy learning the language! 2025-12-13 16:11:17 thanks KipIngram 2025-12-13 17:54:02 Hello o/ 2025-12-13 17:54:20 how many context can forth have? 2025-12-13 17:54:36 public enum Context { Number, Comment, PrintString, Name, IfElse, DoWhile, } 2025-12-13 17:55:06 I can only think of these ones 2025-12-13 21:00:28 ghodawalaaman: I don't generally think of it that way - most of those things don't really correspond to what I would call a "context" - as far as the compiler is concerned it's just executing words. For example, comments of the ( ...) form are just handled by the ( word. IF ... THEN just gets handled by the immediate words IF and THEN; the compiler just looks them up and executes them (since 2025-12-13 21:00:30 they're immediate) the same way it does everything else. Communication between then is handled via the stack, but the compiler itself is oblivious to that communication. 2025-12-13 21:01:07 One of the things that makes Forth so simple and easy to implement is that the compiler doesn't get complicated by trying to handle diverse things like that.