2024-12-18 00:00:21 yeah 2024-12-18 00:00:21 you can patch stuff with early exits or no-ops though 2024-12-18 00:00:29 that's why you don't normally save compiled code, but the jupiter ace is something of an outlier if memory serves 2024-12-18 00:01:01 yep, it can list and edit compiled code 2024-12-18 00:02:01 although if you use token threading it stops being a problem 2024-12-18 00:03:08 what cpu is the jupiter ace? 2024-12-18 00:03:53 cuz going token threaded removes the need for the double increment, which is a hassle 2024-12-18 00:03:53 and it obviously cuts your code size in half, near enough 2024-12-18 00:05:04 you could get a very fast NEXT if you limit yourself to 128 words 2024-12-18 00:05:19 and if you use c02 2024-12-18 00:58:16 the extra DEX on 6502 is only 2 cycles 2024-12-18 00:58:43 ive done time lookup in my 6502 forth and it's definitely slower 2024-12-18 01:04:15 time=token. doh! 2024-12-18 01:58:33 why DEX? 2024-12-18 01:58:53 surely it's DEC mem 2024-12-18 01:58:59 or rather DEC zp 2024-12-18 02:06:15 higher dex is good for a thief, or a ranger 2024-12-18 09:27:45 xentrac: Whether Z80 is slower depends on the clock 2024-12-18 09:29:01 A cheap Z80 was 3.5MHz at the time when a cheap 6502 was 1MHz, e.g. ZX Spectrum vs C64 2024-12-18 09:29:22 (I know it wasn't a 6502 but close) 2024-12-18 09:31:06 But BBC Micro had a 2MHz 6502 which is like lightspeed 2024-12-18 09:31:41 But was a much more expensive machine in UK, very few people had them, although a lot of people I know seemed to be lucky enough to have one! 2024-12-18 09:32:21 And they're very different architectures all round 2024-12-18 09:36:19 Ops in 6502 are usually 2-8 clocks, the fast ops are 2 clocks. Z80 the clocks are usually like 4-16 clocks, fast ops are 4 clocks. 2024-12-18 09:36:51 More actual registers on Z80, means ZX Spectrum could sometimes compete with the BBC Micro even, depending on algorithm 2024-12-18 09:39:38 Ratio from Spectrum to C64 is telling, faster Z80 ops are 4-6 clocks so roughly 1-1.5us. C64 2-3 clocks so 2-3us (?) 2024-12-18 09:39:54 Might have borked numbers but you get idea 2024-12-18 09:40:17 But they are super different archs and both worth learning, I'd say 6502 is actually more interesting to learn 2024-12-18 09:40:35 Because 6502 is quit exotic, Z80 is more like a nasty old x86 ancestor 2024-12-18 09:40:39 quite* 2024-12-18 09:41:06 And it's not simple as I'm making it sound to compare performance 2024-12-18 13:25:49 Hate websites that show time as "2 months ago", or show the date down to the second, or whatever. Please also maintain the healthy illusion that time is consistent and don't tell me whether DST was in effect, just give me the hour. You can put BST/GMT if it's during a leap hour. 2024-12-18 13:26:25 And no I don't want UTC 2024-12-18 14:01:48 Every Forth install should come with an English thesaurus 2024-12-18 14:02:36 So you can find unused synonyms for every noun/verb/adjective you need for your different libraries 2024-12-18 14:08:22 I think [IF] [ELSE] [THEN] is one of the few newer Forth features I actually like 2024-12-18 14:17:41 amby, sorry meant INX not DEX 2024-12-18 14:53:10 veltas: a 3.5MHz Z80 is usually significantly slower than a 1MHz 6502, but it's true that eventually much faster Z80s were available 2024-12-18 14:53:37 Will have to agree to disagree 2024-12-18 14:54:40 the Z80 has some features that make implementing a Forth much more comfortable that are absent in the 8080/8085 (and added in a different form in the 8086) but they are so slow that they generally aren't worth using 2024-12-18 14:55:00 veltas> Hate websites that show time as "2 months ago", seconded 2024-12-18 14:55:45 I'm not sure *why* the speed ratio per clock is so large. You'd think it would be only about 2× or less from what you said above (i.e., a 1MHz 6502 would be slightly slower than a 2MHz Z80) but that isn't my experience 2024-12-18 14:58:46 https://retrocomputing.stackexchange.com/a/5749 has a good summary of my position, also 2MHz Z80 is not what we were discussing 2024-12-18 14:58:57 Apologies if URL is wrong, had to type it in on this shell 2024-12-18 14:59:33 The main factor in play in practice is the software, which a lot of Z80 software was quite inefficient 2024-12-18 14:59:42 Especially Sinclair BASIC 2024-12-18 15:05:01 11 cycles for PUSH is kind of insane 2024-12-18 15:05:55 I think that was the fastest memory throughput of its day, for an 8-bit cpu 2024-12-18 15:06:47 There is a trick to POP/PUSH transfer memory in Z80 that was super quick, was good for very specific ranges 2024-12-18 15:08:06 I guess you can't PUSH to arbitrary pages on the 6502 2024-12-18 15:09:34 not that Dhrystone settles anything, but https://netlib.org/performance/html/dhrystone.data.col0.html rates a 4MHz Z80 (the Cromemco Z2) at 0.05 VAX MIPS, while the 1MHz 65C02 and 6510 machines are 0.021 VAX MIPS, which is in accordance with the 2:1 ratio you're proposing 2024-12-18 15:10:53 or like 1.6:1 even 2024-12-18 15:12:52 Yeah a C benchmark is no good 2024-12-18 15:13:10 This is an old debate though so let's not dwell on it 2024-12-18 15:15:28 I think I've already linked you the Son of the Bride of Cheap Video: https://laughtonelectronics.com/Arcana/KimKlone/BrideOfSon%20KK%20Lancaster.html 2024-12-18 15:16:21 following the Cheap Video Cookbook approach by Don Lancaster (PBUH) 2024-12-18 15:33:16 xentrac: interesting that you said Z80 is slower. the 6502 guys generally say the Z80 is 3-4x slower per mhz 2024-12-18 15:34:55 but yes agreed with veltas that it's an old debate so maybe leave it at that 2024-12-18 15:37:02 yeah, today's architectural debates are much more interesting, but also more difficult 2024-12-18 15:38:46 today's architectures are orders of magnitude more complicated 2024-12-18 15:40:52 and a substantial amount of orders of magnitude, at that - ~4,000,000,000 transistors vs ~8,000 in the Z80 2024-12-18 15:45:22 3500 in 6502 2024-12-18 15:49:47 I feel like the 6502 should have used 6502 transistors 2024-12-18 15:50:53 like the 68000 2024-12-18 15:52:03 i feel like the z80's input impedance should have been 80 ohms 2024-12-18 15:52:31 I don't know, is https://github.com/gsmecher/minimax really orders of magnitude more complex than a 6502? It does have more transistors, but that's like saying that a 16MiB DRAM is three orders of magnitude more complex than a 16KiB DRAM 2024-12-18 15:52:48 I think it's actually simpler if you factor out the repeated structures 2024-12-18 15:53:50 and the https://jlcpcb.com/partdetail/NyquestTech-NY8A051H/C5143390 isn't actually an 8051 despite the part number but doesn't seem much more complex 2024-12-18 15:58:45 I did not know 68k had 68k transistors lol 2024-12-18 15:58:50 on-topic rookie question: is there an idiomatic way to invert a comparison? e.g. if you want to test for >= but your Forth doesn't have a >= word 2024-12-18 15:58:53 News to me 2024-12-18 15:59:03 pgimeno: I use 0= for "not" 2024-12-18 15:59:18 >= is commonly defined 2024-12-18 15:59:27 is it? 2024-12-18 15:59:33 not on the juppy (not even <>) 2024-12-18 15:59:34 Or use < and swap the cases around 2024-12-18 15:59:50 i think f83 only had 0= 0< = < > <> 2024-12-18 16:00:06 Even Forth 2012 doesn't have >= 2024-12-18 16:00:21 well, the 0= will do, thanks 2024-12-18 16:01:01 gforth has those though 2024-12-18 16:01:48 pgimeno: there's invert but that's a bitwise inversion (-1 xor) so 0= is a little safer if what you're looking for is zero or non-zero 2024-12-18 16:03:21 definitely, = returns 1 anyway, not -1, so invert wouldn't work there (and isn't in the Juppy) 2024-12-18 16:03:50 that's unusual. in forth truth is usually indicated with -1 2024-12-18 16:05:14 according to forth-79, "[...] all standard words return one when leaving a ' true' flag" 2024-12-18 16:05:46 huh 2024-12-18 16:06:17 nevermind me then 2024-12-18 16:11:32 0= is shorter, that's the main reason i use it 2024-12-18 16:11:49 I know that's bad, I am just beyond caring 2024-12-18 16:12:21 It's also faster than INVERT on my Z80 Forth 2024-12-18 16:12:31 yeah, you can use invert 2024-12-18 16:12:41 old Forths had not 2024-12-18 16:12:58 the problem is that in some old Forths not was 0= and in others it was invert 2024-12-18 16:13:27 Exactly 2024-12-18 16:13:38 F83 does in fact have >=, zelgomer 2024-12-18 16:13:54 0/2 so far today 2024-12-18 16:14:00 In common extensions probably, not in core 2024-12-18 16:14:04 possibly you are thinking of Forth-83 2024-12-18 16:14:17 I see what you mean now 2024-12-18 16:14:35 i honestly didn't know those were two different things. maybe i should just see myself out. 2024-12-18 16:14:43 jonesforth has not, invert, and negate 2024-12-18 16:14:52 To be fair I would expect F83 to mean the standard most times 2024-12-18 16:14:55 which are bool, bitwise, and arithmetic respectively 2024-12-18 16:15:05 But that's probably not a fair assumption 2024-12-18 16:15:11 it's in utility.fs: : >= (S n1 n2 -- f ) < NOT ; 2024-12-18 16:15:21 screen 2 2024-12-18 16:15:51 Forth-83 is the standard, and F83 is Laxen and Perry's "model" implementation of the standard (which didn't actually come out until 01984) 2024-12-18 16:16:06 i see 2024-12-18 16:17:04 I think the reason that in Forth-83 things like 0= and 0< return -1 for "true" is so that either definition of not will work on them 2024-12-18 16:17:49 in F83 not is invert, i.e., bitwise not, C's ~ 2024-12-18 16:17:57 I'm not sure if it's defined in Forth-83 2024-12-18 16:18:45 I realize now that I'm repeating things zelgomer already said 2024-12-18 16:19:47 Using -1 for 'true' probably makes Forth slower 2024-12-18 16:20:02 And provides almost no benefit, if any 2024-12-18 16:20:09 how do you figure that? 2024-12-18 16:20:23 Having written the code for Z80 and x86 2024-12-18 16:21:02 -1 for true provides benefit because you can and it with a value to make a branchless ternary predicate ? x : 0 2024-12-18 16:21:13 Most of the operators returning flags are a bit weird, and clearly have more steps. I've not benchmarked it on x86 though 2024-12-18 16:21:16 Maybe I will one day 2024-12-18 16:21:34 There are benefits to both 1 and -1, depends on the context 2024-12-18 16:21:40 That's a small benefit I've never used zelgomer 2024-12-18 16:22:04 i have used it to implement branch as a high level word :) 2024-12-18 16:22:27 which i admit is probably just a neat trick and not something i would ever use in a real program 2024-12-18 16:22:36 s/branch/0branch/ 2024-12-18 16:23:13 I'm just dropping truth bombs 2024-12-18 16:29:30 pushing booleans on the stack makes Forth slower and provides no benefit 2024-12-18 16:29:42 : bomb drop truth dup recurse ; 2024-12-18 16:29:58 (in the usual case where the boolean is immediately consumed to control a conditional) 2024-12-18 16:30:57 You can say that about a lot of Forth words really 2024-12-18 16:31:43 it's about the language-design decision to use the truth-functional interpretation of propositional logic, in which things like `>` are boolean-valued functions 2024-12-18 16:32:46 which is a perfectly workable decision, and one used by many languages (Fortran, Lisp, C), not to mention circuit design, but not a close match to CPU instruction sets 2024-12-18 16:33:15 in which things like `>` are most commonly implemented as conditional branches 2024-12-18 16:34:09 the amd64 architecture actually has separate `cmp` and `jg` instructions which it has to fuse into a single `bgt` macro-op in its front-end in order to get reasonable efficiency 2024-12-18 16:34:27 I should say, which its implementations have to fuse 2024-12-18 16:35:00 condition code registers make pipelining harder, or something 2024-12-18 16:35:16 At least in Forth you can use something like CMP as a low-level word and build on that, and then arch-specific code can use it directly 2024-12-18 16:35:18 that's not why 2024-12-18 16:35:43 it's because executing one micro-op is faster than executing two micro-ops with a dependency between them 2024-12-18 16:36:07 the condition code register being the dependency 2024-12-18 16:36:18 yes, but putting it in an explicit register like POWER doesn't help 2024-12-18 16:36:19 in Forth you also have the result that the truth-functional interpretation makes your code harder to read 2024-12-18 16:36:42 yes 2024-12-18 16:37:00 the specific thing with having the dedicated condition code register is that everything wants to touch it 2024-12-18 16:37:06 and it gets really hard to reorder stuff 2024-12-18 16:37:38 which i believe is why arm has a bit in the instruction encoding that specifies whether the instruction should write to the status register or not 2024-12-18 16:40:49 yes, that is also true, but that is not what I am talking about 2024-12-18 16:42:17 xentrac: why do you say truth-functional interpretation makes your code harder to read? 2024-12-18 16:42:17 I don't know why ARM has that bit in the instruction encoding but I don't think it's to facilitate out-of-order execution. Even superscalar execution was not on the table for ARM or in general for RISC in 01985 2024-12-18 16:42:32 well, it's because I'm comparing it with an alternative which I haven't shown you 2024-12-18 16:42:52 show me 2024-12-18 16:43:09 x86 is more of the exception than the rule on this, most surviving archs I've seen have some or a lot of flexibility on whether condition bits are affected 2024-12-18 16:44:07 The condition bits in ARM instructions were to avoid branches 2024-12-18 16:44:33 GeDaMo: yes, but why is there a bit to preserve the condition register in things like `add`? 2024-12-18 16:44:54 zelgomer: okay, so, in the alternative, Comforth, loops and conditionals push unresolved jump targets onto the compile-time stack, and comparison operators compile conditional jumps to those jump targets rather than pushing booleans on the stack 2024-12-18 16:44:59 Maybe you want to add without needing the result of the flags 2024-12-18 16:45:36 why is that so important as to merit a bit in the instruction format, though? 2024-12-18 16:45:54 Maybe it just seemed like a good idea at the time :P 2024-12-18 16:46:14 maybe! but it was a popular idea, as veltas points out 2024-12-18 16:47:01 so, in Forth, you might write : abs dup 0< if negate then ; while in Comforth you would write : abs if dup 0< then negate fi ; 2024-12-18 16:47:18 If I remember correctly, Arm didn't have a simple mov instruction, you used add or or with the zero register 2024-12-18 16:47:30 You wouldn't want those to affect the flags 2024-12-18 16:47:40 Or maybe you would :| 2024-12-18 16:47:45 doesn't it? 2024-12-18 16:48:09 xentrac: what if i wanted to factor dup 0< into another word? and what does then do there? 2024-12-18 16:48:36 I'm reasonably sure that any 'mov' was a pseudo instruction mapping to add or or 2024-12-18 16:49:58 the Comforth comparison operator doesn't pop the jump label off the stack, so you can do a conjunction of conditions just by writing them one after the other. then pops a jump label off the destination stack but leaves it on a stack for fi or else to resolve 2024-12-18 16:50:53 so the 0< compiles to a conditional jump to the fi 2024-12-18 16:51:03 like : dup0< if dup 0< then -1 else 0 fi ; 2024-12-18 16:51:25 This is like powerpc 2024-12-18 16:51:27 which you then would have to use as : abs if dup0< 0<> then negate fi ; 2024-12-18 16:51:38 mov is a pseudo in PPC as well 2024-12-18 16:51:54 xentrac: i see 2024-12-18 16:51:59 also in RISC-V, but I don't think it actually is in ARM 2024-12-18 16:52:22 Possibly I'm thinking of MIPS 2024-12-18 16:53:14 an example of the conjunction of conditions is : isupper if dup [char] A >= dup [char] Z <= then drop -1 else drop 0 fi ; 2024-12-18 16:53:56 mov reg,reg in arm is an alias of ORR 2024-12-18 16:54:03 a while loop contains two parts 2024-12-18 16:54:08 veltas: aha, thanks 2024-12-18 16:54:37 According to the arm website, anyway 2024-12-18 16:55:21 in a Comforth while loop you have begin while loop. A comparison failure in jumps to the end of the loop. A comparison failure in jumps to wherever a comparison failure outside the loop would have jumped to 2024-12-18 16:56:12 The Smalltalk-80 virtual machine didn't have a conditional branch instruction, it used value dispatch, essentially a lookup table 2024-12-18 16:56:50 this means that the Comforth while-loop (and do-loop, which works the same way) is implicitly a universal quantifier. If you want to test whether something is true of every character in a string, for example, you can loop over all the characters in the string, testing each one. If one of them fails the test, the loop as a whole fails. 2024-12-18 16:57:27 (this requires a little trickery to ensure that do-loop loop control variables are popped properly when exiting the loop in the middle, but it's not very much) 2024-12-18 16:58:14 arm is actually a psuedo leg 2024-12-18 16:59:07 it also means that any ordinary while loop has an extra potential exit available, which is useful in almost every case where you want to break out of a loop early 2024-12-18 17:01:06 in Comforth you can write if begin dup 0<> while dup keyfield searchkey <> nextfield loop then else fi to search a linked list 2024-12-18 17:01:13 for example 2024-12-18 17:01:43 i was just typing trying to find a clear way to ask this. so the answer is yes, to get your early break you surround the loop with an if-fi 2024-12-18 17:01:53 if the searchkey <> test fails, you go directly to the found case 2024-12-18 17:03:37 so my argument is that Comforth is (a) closer to conventional conditional syntax than standard Forth, and (b) more efficient than standard Forth with a conventional implementation 2024-12-18 17:04:07 i'll buy (b). i'm on the fence about (a). 2024-12-18 17:04:11 more arguable is that it is (c) more expressive 2024-12-18 17:04:42 well, (a) i agree it's more conventional. it's your claim earlier about it being more readable that i'm on the fence about. 2024-12-18 17:04:55 yeah, I shouldn't have said "more readable" 2024-12-18 17:05:15 I mean, it *might* be. certainly it's more readable if you don't know Forth, but that's not saying much 2024-12-18 17:05:42 but does it actually end up being more readable once you know it and also know standard Forth? I don't know 2024-12-18 17:05:49 only because consistency of rpn is lost. rpn is definitely not the norm, that's true, but i think for readability, consistency is near the top of importance. which is also why i really don't like parsing words generally. 2024-12-18 17:06:10 consistency of RPN is lost with control structures of any kind, though 2024-12-18 17:06:38 unless you pass quotations factor-style, yeah i guess that's true 2024-12-18 17:06:59 right, that is indeed the consistent way to do it. it's what PostScript does 2024-12-18 17:07:25 I'm not sure about GeDaMo's assertion about the Smalltalk-80 VM (which is also RPN for expressions 2024-12-18 17:07:28 ) 2024-12-18 17:07:31 so, more dataflow style then? 2024-12-18 17:08:09 dunno, how so? 2024-12-18 17:08:49 I mean, dataflow instead of control flow style of code 2024-12-18 17:08:49 I think RPN generally has poor readability, but I know that for example veltas disagrees, and it's possible that that's just a subjective judgment on my part, or a learning disability :) 2024-12-18 17:09:10 which, Factor/PS? Or Comforth? 2024-12-18 17:09:13 I find infinx notation less readable than rpn 2024-12-18 17:09:21 Factor and PS are sort of more dataflowy; Comforth isn't 2024-12-18 17:09:54 I think that's plausible, but what I really mean is that RPN is less readable than prefix notation 2024-12-18 17:10:58 In Smalltalk a conditional is something like: value ifTrue: [...block...] ifFalse: [...block...]; with 0 for false and 1 for true, it's basically like indexing into an array of blocks 2024-12-18 17:11:51 SmallTalk80/Squeak 'syntax' I take it 2024-12-18 17:12:29 I'm a bit vague on the exact syntax but yes 2024-12-18 17:12:53 I sometimes use this style in js using arrow function syntax 2024-12-18 17:14:42 I feel like Chuck put some kind of indexed jump into Colorforth, something like ... jump first second third ... 2024-12-18 17:15:21 'jump' would read the top of stack and jump to the indexed word following, e.g. 0 would jump to 'first' etc. 2024-12-18 17:15:38 reminds me of the branch instr in IBM 390 2024-12-18 17:15:55 oh, that is just a jump table 2024-12-18 17:16:00 Yes 2024-12-18 17:16:43 that is usually how I implement the equiv of switch statements 2024-12-18 17:26:43 indexing into an array of blocks in Smalltalk would I think be ({[...block...] [...block...]} at: value) value. 2024-12-18 17:26:59 but I'm not 100% sure that's valid syntax 2024-12-18 17:27:23 but the *syntax* is a different question from how the *VM* works 2024-12-18 17:28:12 which I believe uses a conditional jump bytecode 2024-12-18 17:29:49 It seems I'm wrong, there are conditional jumps http://www.mirandabanda.org/bluebook/bluebook_chapter28.html#JumpBytecodes28 2024-12-18 17:31:08 yeah 2024-12-18 17:31:39 though note that, as with Forth, it relies on pushing boolean values onto the stack 2024-12-18 17:31:54 Yeah 2024-12-18 17:32:12 at the syntactic level, the syntax is method-call syntax, calling the method #ifTrue:ifFalse: 2024-12-18 17:33:05 but the compiler special-cases that selector in order to avoid the cost of allocating the block objects 2024-12-18 17:33:49 yebb, pretty neat 2024-12-18 17:34:20 I was sort of saying the opposite ;) 2024-12-18 17:34:45 it's a pretty unfortunate kludge 2024-12-18 17:36:59 Using a jump table for a conditional branch is a valid strategy, I'm not sure how I got the idea that Smalltalk worked like that though :| 2024-12-18 17:39:33 aforesaid IBM 390 uses fourway conditional code conditional jumps btw 2024-12-18 17:40:43 I think RPN Is clear but forth-style words without parentheses to show what's a function and how many arguments there are is what makes it hard to parse 2024-12-18 17:42:32 how do you display how many items a forth word would leave on the datastack? 2024-12-18 17:44:13 "Comforth", FWIW, is just the application of Henry Baker's "Comfy" control-flow structures to Forth to replace the standard Forth control structures 2024-12-18 17:45:09 where can I read about those? 2024-12-18 17:47:06 "The COMFY 6502 Compiler" https://dl.acm.org/doi/pdf/10.1145/270941.270947 ? 2024-12-18 17:48:09 yeah, and the 8080 version as well 2024-12-18 17:48:51 but I think the 6502 column is better-thought-out. the 8080 one takes some shortcuts that I think Baker regretted later 2024-12-18 17:54:56 are there any kind of reserved symbols or prefixes or the like, like in C? or is that just a non-concern because they are not truly reserved words anyway? 2024-12-18 17:56:11 For Forth in general? There are no reserved names 2024-12-18 17:56:20 nope. you just can't name anything with whitespace characters. 2024-12-18 17:56:21 You can redefine anything 2024-12-18 17:56:30 ^ including numbers 2024-12-18 17:56:37 Depending on how you define 'whitespace' :P 2024-12-18 17:56:56 ok, spaces 2024-12-18 18:15:46 pgimeno: as noted by zelgomer & GeDaMo other than whitespace, not in most systems 2024-12-18 18:16:29 in some, like mine (retroforth, konilo), sigils are checked before a dictionary search is done, so word names starting with defined sigils won't be found directly. (Still callable, but not as easily) 2024-12-18 18:16:55 if using a relatively standard system, you won't run into this 2024-12-18 18:17:29 I see, thanks 2024-12-18 19:45:22 I've just found https://www.fourmilab.ch/atlast/ 2024-12-18 19:45:54 looks quite cool, I hope it's similar in spirit to s7 scheme 2024-12-18 19:46:08 both are just 2 c files to add into your program 2024-12-18 19:46:35 if adding new words is easy so even I can do it, then I've got a big win 2024-12-18 19:46:49 supposedly is inspired in forth83, but no idea on how much 2024-12-18 19:47:14 forth83 seemed to be a cool and popular forth 2024-12-18 19:47:57 just downloading the tar and typing make works fine 2024-12-18 20:01:26 Lua's quite easy to integrate, and pure C 2024-12-18 20:02:26 Vanilla Lua's not very fast, it's now 'slow' for interpreted either. LuaJIT has very good performance though 2024-12-18 20:10:53 A lot of projects now are just called "A Modern X written in Rust" or "A Modern X written in Go". Can I make "A Modern X written in Forth"? 2024-12-18 20:11:04 I think I can, as I live in the modern era 2024-12-18 20:11:38 how modern is forth? 2024-12-18 20:11:52 actually it is relatively modern 2024-12-18 20:12:24 just unknown 2024-12-18 20:15:15 I have a bit of interest in this atlast forth since I could make it work with emscripten 2024-12-18 20:15:49 then I can just add bindings to sdl and be able to both use sdl in desktop and to get that translated in webassembly + js 2024-12-18 20:16:21 or just add bindings through em_js 2024-12-18 20:25:36 A load of Forth discussion on 4chan tonight https://boards.4chan.org/g/thread/103521394 2024-12-18 20:57:58 works fine with emscripten (the 32 bit version) 2024-12-18 20:58:13 I just need to learn how to add bindings 2024-12-18 20:59:01 veltas: a modern forth written in forth 2024-12-18 20:59:16 there is an example already https://termbin.com/uk8z 2024-12-18 20:59:30 that push macro looks funny 2024-12-18 21:01:06 my pushes in c look similar. i just don't hide it behind a macro. *push(&sp) = ...; 2024-12-18 21:07:37 zelgomer: lol 2024-12-18 21:40:43 it's extremely easy to add your own stuff into that forth :0 2024-12-18 21:40:45 https://termbin.com/scjj 2024-12-18 21:41:06 you can access the memory, the stack and the return stack also 2024-12-18 21:41:22 https://www.fourmilab.ch/atlast/atlast2.html 2024-12-18 21:42:03 I think I've found what I wanted 2024-12-18 21:44:09 the 0 at the word name in that struct is the immediate bit 2024-12-18 21:45:18 there is no count, and type does not expect a count, just the string address 2024-12-18 21:45:37 strings seem to be more c-like 2024-12-18 21:47:05 but it's just two c files that you add to your code and start adding bindings, exactly like s7 scheme but even easier 2024-12-18 21:47:36 vms14: have you been able to figure out how it models the dictionary? 2024-12-18 21:47:45 the memory, i mean? 2024-12-18 21:47:52 no, my main concern was ffi 2024-12-18 21:48:03 but should be documented 2024-12-18 21:48:05 i think it's just a single flat malloc but i don't find this code particularly easy to follow 2024-12-18 21:48:22 https://termbin.com/42db 2024-12-18 21:48:25 this is the c file 2024-12-18 21:48:42 and the header 2024-12-18 21:48:43 https://termbin.com/8eo7 2024-12-18 21:49:13 memstat 2024-12-18 21:49:33 i'm pretty sure he just allocates 1000 cells at init and that's where user created words go 2024-12-18 21:49:54 was just curious to see how other people are doing that 2024-12-18 21:50:53 i've recently settled on a pretty simple block management thing i'm kind of proud of 2024-12-18 21:51:38 I was thinking about how I would do it if I make some rpn lang in c 2024-12-18 21:51:49 I would just have a normal array I guess xd 2024-12-18 21:52:00 https://termbin.com/7fc2 2024-12-18 21:52:36 i'm sure it's not the fastest thing on earth, but that wasn't my goal 2024-12-18 21:53:14 for now I'm happy if I can just mess with this forth 2024-12-18 21:53:47 I will start adding bindings to whatever I want, although the main interest is in emscripten 2024-12-18 21:54:02 but I will also try to use it for scripting or alike 2024-12-18 21:54:24 it's exactly what I wanted, a forth easy to embed and extend 2024-12-18 21:55:16 I could go as far as to use android studio and add bindings through java jni and native c, but I will just use emscripten xd 2024-12-18 21:55:57 if I add bindings to sdl emscripten translates them, but at the end I will want to add bindings for the dom and alike 2024-12-18 21:56:05 I guess it already had something 2024-12-18 22:51:33 pgimeno: recent versions of the Forth standard have adopted prefix characters for character, decimal, and hexadecimal constants, but that doesn't stop you from redefining those constants. Consider this interaction with GForth: 'a' emit : 'a' 'b' ; 'a' emit ab ok 2024-12-18 22:52:04 that is, at least in GForth, the sigils are checked after the dictionary search is done (as is traditional for numbers) 2024-12-18 22:52:48 vms14: Forth-83 is the Forth standard to which ATLAST complies; you cannot download a tar of it and type make. F83 is an earlier implementation of that standard 2024-12-18 22:53:19 I think vanilla Lua is in the same ballpark as indirect-threaded Forth 2024-12-18 22:53:34 xentrac I can download the tar of atlast and type make 2024-12-18 22:53:36 I like this idea of building atlast with sdl in emscripten! 2024-12-18 22:54:08 also tried to compile it with emcc and worked fine as long it's the 32 bit version 2024-12-18 22:54:16 so I just need to start adding bindings 2024-12-18 22:54:21 aha, I see 2024-12-18 22:54:35 (I guess I should have realized that F83 doesn't come with a Makefile) 2024-12-18 22:54:37 the only sad thing is that the author of this forth seem to have died this february 2024-12-18 22:54:43 yes, he did 2024-12-18 22:55:54 rude 2024-12-18 22:56:56 I don't think he did it on purpose 2024-12-18 22:58:24 xentrac: nice to know, thanks 2024-12-18 23:42:40 Don't try to sell me an atlas, I'm not that stupid