2022-01-06 10:50:38 I wonder why they didn't prefer 1 cell for the count byte in counted strings. 2022-01-06 10:52:56 More complicated, unnecessary in situations where you'd usually want a counted string, also COUNT is more useful taking the first byte because it can be used to enumerate a string 2022-01-06 10:53:52 In retro everything is a cell and so counted strings / counted arrays are all the same if I remember right 2022-01-06 10:54:17 I don't understand. How is it any more complicated to use a cell instead of byte? 2022-01-06 10:56:26 It's just a little bit easier to increment things by 1 than 2 2022-01-06 10:56:37 And as I said it makes COUNT less useful 2022-01-06 10:56:56 And it saves 1 byte of space, that's another reason 2022-01-06 10:57:21 COUNT in that case would use cell + instead of 1+ (and @ instead of c@, etc.). 2022-01-06 10:57:43 Actually, for the converse: in what situation do you want a string that can't fit in a counted string? 2022-01-06 10:58:35 Strings in FORTH are usually for display or naming, so 255 chars "out to be enough for anyone" 2022-01-06 10:58:42 ought* 2022-01-06 11:00:32 I feel that's an unnecessarily complex over thinking to consider whether how much the string size can be at most or at least (we just don't know, nor care). My reasoning is like this: 1) I need a counted string. 2) I can store the count in first cell (because cell is an obvious choice). 2022-01-06 11:01:19 I think I felt the same way at some point 2022-01-06 11:01:27 I guess I'm jaded to it now 2022-01-06 11:02:19 Saving space and COUNT for traversal seem to be the advantages 2022-01-06 11:02:37 Support for strings longer than 255 is advantage for alternative 2022-01-06 11:02:48 We disagree about which is 'simpler' so I think that's probably a bit more subjective 2022-01-06 11:02:52 I agree that we have no use for long strings (especially in a minimal system), and if you do need, then you need to create a string word set anyway. 2022-01-06 11:03:12 Well we have a string wordset anyway 2022-01-06 11:04:43 True, it boils down to the complexity of string processing problem you need. I found it easier to work with strings after I created things like s:nth, s:tokenize, s:char-at, etc. 2022-01-06 11:05:13 But it was far less efficient, and not very FORTHy in the traditional sense. 2022-01-06 11:07:21 Keep trying the old ways, I think I find more often than not that the 'traditional' way is sufficient and I've just gotten unnecessarily used to the modern approach 2022-01-06 11:11:27 Kind of unrelated but, I'm still searching (the ways of programming). I have a problem with being consistent and stable at one thing for too long (which sucks), I eventually come back to it after a period of activity in the opposite direction. My personal projects suffer from this, as I stop before finishing. 2022-01-06 11:12:39 I've so many unfinished projects that's been lingering over a year at least. 2022-01-06 11:13:05 I should set milestones and conside them done 2022-01-06 11:14:31 And there's the day job, which takes most of the productive energy. Need to take a break from working for at least a year and more, and just focus on what I love doing. 2022-01-06 11:17:05 Yeah you pretty much described me 2022-01-06 11:17:18 The last 4 lines are an accurate depiction of myself right now 2022-01-06 11:17:59 Don't worry you can still learn and get good stuff done, you might need to get better at resuming old projects when you're closer aligned with them in future 2022-01-06 11:18:06 in theory 2022-01-06 11:18:45 I finished zenv in two sprints, about a year apart, so I managed to come back to it and just "get it done", will probably go back to it again at some point 2022-01-06 11:19:26 Right now I'm doing like 1-2 lines of my x86 forth at a time it feels like, but sometimes I'll stay up all night and do loads 2022-01-06 11:22:54 Was zenv not possible to "port" to x86 almost with 1:1 correspondence? 2022-01-06 11:23:35 I started my Forth for Z80 first, then decided I can do it with x86 first (for easier iteration), but I keep in mind that I will try to rewrite the core in Z80 later on. 2022-01-06 11:24:28 At this point it's functional I'd say, but I want to make it standard compliant (sometimes these kind of perfectionist ideas stop me from finishing projects). 2022-01-06 11:32:31 Z80 is definitely an ancestor of x86, but it's so different that I have been 'writing from scratch' 2022-01-06 11:32:54 Sometimes I look at zenv for high-level stuff, because the colon defs aren't going to change much 2022-01-06 11:34:30 And I am keeping code and data separate for performance reasons, and using subroutine threading because I want to add optimisations later 2022-01-06 11:35:15 Do you use relative far for subroutine calls? 2022-01-06 11:36:25 That made some parts ugly (like COMPILE/POSTPONE), because from the relative address you need to re-construct the absolute. 2022-01-06 11:37:47 relative near, I'm on x86-64 2022-01-06 11:38:15 I should probably say x86-64 since there are 3 broad arch's called "x86" 2022-01-06 11:43:46 I was going to make it non-standard and then I realised I'm not important or intelligent enough to get anyone to use my FORTH if it's non-standard 2022-01-06 12:09:46 That too, but my main motivation is to first get the standard right before coming up with a subjectively better way of doing things. 2022-01-06 12:10:10 Although my COUNT works with CELL, heh 2022-01-06 14:24:51 what is the forth word to convert a counted string or s" string" ( -- a n ) to a null terminated C string? 2022-01-06 14:28:20 mhhh I am not a forth expert but I do not know of one 2022-01-06 14:46:52 why would you need that :P 2022-01-06 14:56:15 joe9: no standard word for that 2022-01-06 14:56:18 to interact with the C bindings. 2022-01-06 14:56:35 crc, are you aware of any code doing that? 2022-01-06 14:56:47 thanks. 2022-01-06 14:58:38 s"\ null string\z" drop ( if using gforth ) 2022-01-06 15:00:47 I might be able to write a proper conversion word in a little bit (heading home from work; will see when I arrive) 2022-01-06 15:05:01 what does ##forth think about fraglets. 2022-01-06 15:05:42 http://www.fraglets.net/ 2022-01-06 15:43:07 : zt ( addr u -- zstring ) here -rot 0 do dup c@ c, char+ loop drop 0 c, ; 2022-01-06 15:47:52 joe9: this will convert a standard string to a null terminated one 2022-01-06 16:09:19 `?do` instead of `do` to support 0-length string 2022-01-06 16:09:32 thanks. 2022-01-06 16:13:17 veltas: I forgot about that 2022-01-06 16:13:36 : zt ( addr u -- zstring ) here -rot 0 ?do count c, loop drop 0 c, ; 2022-01-06 16:17:38 what does s" do? puts the counted string address on the stack? 2022-01-06 16:18:35 No, when compiling it puts it with the colon def code usually, and in interpreter it puts it in one of two special buffers 2022-01-06 16:18:56 It alternates those buffers so you can have two s" interpreted strings before overwriting a previous string 2022-01-06 16:19:13 why not use pad instead? 2022-01-06 16:21:10 Because pad is reserved for the programmer, so no system words touch it 2022-01-06 16:22:19 Although it's 'transient' in recognition that often its position is somewhere past `here` 2022-01-06 16:28:35 what are the inputs for sliteral? 2022-01-06 16:29:05 addr u at compile-time 2022-01-06 16:29:08 Of string 2022-01-06 16:29:10 I understand literal, it puts the n on the stack into the dictionary with a cfa of literal. 2022-01-06 16:29:34 it is countedString count 2022-01-06 16:29:36 thanks. 2022-01-06 16:34:33 joe9: No not countedstring 2022-01-06 16:34:56 If it was a counted string it would not specify size as well 2022-01-06 16:50:23 ok, thanks. 2022-01-06 17:10:15 I spill so much coffee at work 2022-01-06 17:10:29 Get it all over the floor, on my desk, ... 2022-01-06 17:35:05 > It alternates those buffers so you can have two s" 2022-01-06 17:35:08 I had not thought about this 2022-01-06 17:35:19 How about when you have three and more? 2022-01-06 17:53:12 Did you catch the use of `count` above? 2022-01-06 17:53:40 Doesn't work with your count though 2022-01-06 17:54:57 The standard words it really badly, it says "may be implemented in a circular arrangement" but that "may" should really say "shall" 2022-01-06 17:55:14 re "three and more" 2022-01-06 18:05:47 I see. (the circular arrangement) 2022-01-06 18:06:00 Your use of count is a little cryptic to me (I got crc's version). 2022-01-06 18:06:31 How does it work when there's no counted string involved in the use of s" 2022-01-06 18:06:58 what is the difference between c" and s" 2022-01-06 18:07:00 ? 2022-01-06 18:08:26 c" leaves the address of a counted string, and s" leaves the address and count. 2022-01-06 18:08:47 ok, thanks. 2022-01-06 18:10:41 I remember the author of retroprogramming.com was hanging out here. If you're reading this, your last post is from 2017, any plans of making more posts? 2022-01-06 18:42:16 neuro_sys_: : count ( a - a+1 a[0]) 2022-01-06 18:42:46 That's all count does, it gives you the address of next character and the first character 2022-01-06 18:43:31 It happens to give you a counted string's "c-addr u" pair, but also lets you traverse a string 2022-01-06 18:46:35 Wow, right 2022-01-06 19:00:16 BTW, that pseudo code is kind of a nice syntax, hmm. 2022-01-06 21:15:14 what are the use cases of " and c"? " ( -- a n ) and also puts the string in the dictionary 2022-01-06 21:15:29 c" is similar to " except that it only puts the address on the stack. 2022-01-06 21:15:43 the comments mention that they are used in interpreter mode. 2022-01-06 21:25:22 c" is a counted string.. the first char has the length of the string, then the string starts at the second char 2022-01-06 21:26:58 standard forth has them compiled into definitions 2022-01-06 21:27:37 it is compiling the counted string into the dictionary with felix forth too. 2022-01-06 21:28:35 http://okturing.com/src/12932/body 2022-01-06 21:29:05 I am trying to come up with a test case for " and c" 2022-01-06 21:29:12 t ' 10 : showstuff " /tmp/test" ; type ' '/tmp/test10' 2022-01-06 21:29:26 this test fails 2022-01-06 21:29:50 after showstuff is compiled, I assume the stack has the address and n on the stack. 2022-01-06 21:29:59 so, type could use them.