2023-01-17 00:36:36 KipIngram: do you use some kind of array data in your forth? 2023-01-17 00:36:55 I'm going to do some of the https://www.ic.unicamp.br/~meidanis/courses/mc336/problemas-lisp/L-99_Ninety-Nine_Lisp_Problems.html 2023-01-17 00:37:04 it's taken from prolog I guess 2023-01-17 00:37:20 but being lisp problems it's quite focused on lists 2023-01-17 00:38:10 I think is good for me in my case, as I'll end with a lot of words to operate with lists 2023-01-17 00:38:19 and lists are my main data type 2023-01-17 00:38:53 colon words are lists, and most of the words expecting code can also take lists as code 2023-01-17 00:40:02 mainly a word expecting code will call evaluate() which evaluates lists or strings, if it's something else it just pushes it on the stack 2023-01-17 00:40:27 so for example [ 1 2 3 ] [ . ] do.list can also be [ 1 2 3 ] '. do.list 2023-01-17 00:41:04 the string has to be an atom, not an arbitrary string of code 2023-01-17 00:42:30 https://termbin.com/xw3na 2023-01-17 00:42:41 [[d],[c,d],c] 2023-01-17 01:00:56 No, I've no array support in particular at this time. 2023-01-17 01:01:33 I eventually intend to have an ability to have arrays, lists, and so on, but I'll view that as an element of an "application" rather than as part of the native Forth system itself. 2023-01-17 01:01:52 That'll involve those 64-bit "typed entity" items I've talked about. 2023-01-17 01:01:56 well in a real forth an array can be as simple as using the comma 2023-01-17 01:02:49 Sure, loading one via the interpreter. 2023-01-17 01:03:06 Rudimentary arrays aren't hard to add to Forth. 2023-01-17 01:03:23 still for me I think is good to do those exercises as I focus a lot on lists 2023-01-17 01:03:36 You could easily write support for something like 2023-01-17 01:03:45 [] 2023-01-17 01:03:56 which would leave the address of array[index] on the stack. 2023-01-17 01:04:00 for example now I have to do the palindrome predicate for a list 2023-01-17 01:04:10 which means I'll end with a way to compare lists 2023-01-17 01:04:52 yeah, and do like counted strings, having the len as the first element or whatever 2023-01-17 01:05:22 then is easy to start adding iterators and alike 2023-01-17 01:06:37 Possibly, yeah. 2023-01-17 01:07:25 I plan (eventually) to store arrays within a ropes data structure. Iterators will know how to walk those structures. Smalla arrays, that fit in one ropes page, you'll be able to use usual methods, if you want. 2023-01-17 01:14:18 : list.palindrome dup reverse list.equal ; 2023-01-17 01:14:19 [ 1 2 3 2 1 ] list.palindrome => 1 2023-01-17 01:15:51 but list.equal sucks so much 2023-01-17 01:16:04 can only compare lists with numbers or strings 2023-01-17 01:16:25 I should change it 2023-01-17 03:42:27 Ugh what is it with libera.chat / old-freenode staff and their announcements, loudest mods on any IRC network by far 2023-01-17 03:43:08 turn wallops off. 2023-01-17 03:43:14 I don't actually care if nickserv will stop working temporarily, I'll know if it happens. Send maybe a single message to people subscribed to wallops, don't send like 3 2023-01-17 03:43:55 It's worth having them on I just think it's really bizarre how they're the only network with this kind of wallop culture 2023-01-17 05:22:24 KipIngram: ya stack of pointers to any type of data is a great idea. Have you played with any of the 48/49 calculators? Lots of awesome ideas there 2023-01-17 07:22:50 My wife uses a 48GX. She came along ten years after me, so it's just what was current when she was in school. 2023-01-17 07:23:32 I've only played with it a little. 2023-01-17 07:23:49 Kind of interesting "directory structure" like setup. 2023-01-17 09:18:53 Ah, DM-41x is now in the Houston area. 2023-01-17 09:27:49 MrMobius: I think it's a slick idea too. A "real" Forth system is designed to be a very low level thing, for poking at hardware and things like that, so in that case the standard integer stack is the way to go. But it seems pretty clear to me that for a more "application level" environment, where you're wanting to do serious analytical computations, a stack that can hold more abstract items is preferable. 2023-01-17 09:28:11 A Forth aimed at providing a calculator OS would be such a case. 2023-01-17 09:28:58 Which certainly doesn't mean that it couldn't be running on top of an integer stack base Forth system. I'm talking only about the "visible" stack at the application level. 2023-01-17 10:07:13 Seems to me that approach opens all possibilities up. Your stack items could be any kind of numeric structure (arrays, etc.), but they could also be general data structures that represented, say, a symbolic expression, so you could do CAS stuff too. 2023-01-17 10:37:03 On this WP34S emulator, quite a few shifted key functions open "catalogs." Then you use up and down arrow keys to scroll around in those, and when you find what you want you can hit the XEQ key, which will either execute it or insert it into a program, depending on what you're doing. 2023-01-17 10:38:17 I think on a touch-screen calculator that's not really a good use of key space. I think I'd instead have a double-tap open a catalog list. You could roll it up and down with your fingers, and when you tapped an enttry it would open that catalog and you'd do the same there to get your selection. 2023-01-17 10:38:33 Then all of the keys themselves could be reserved for things that "run right now." 2023-01-17 10:38:57 Specific operations, rather than access to an "operation selection" process. 2023-01-17 10:39:39 I haven't counted, but I imagine that the entire list of catalogs would fit on the screen all at once, so you probably wouldn't need to scroll the catalog list. 2023-01-17 10:40:10 And you also probably wouldn't need to scroll many of the catalog content lists either - most of them aren't THAT long. A couple are. 2023-01-17 10:51:34 Also, the keys on this emulator are the same size as the keys on the calculator. There's a good bit of space in between keys that's used for function callouts. 2023-01-17 10:52:05 I think on a touch screen calculator the keys should be as large as possible. You're losing the tactile feedback, so anything you can do to make hitting the keys more reliably is a win, I think. 2023-01-17 10:52:33 So I think I'd have very small gaps between them, and any writing you wanted would be ON the keys. 2023-01-17 10:53:27 I'd write the primary function on top in larger font, and the shifted functions on line two in a smaller, color-coded font. Then when you hit a shift key the keys would re-label so that the function that went with that shift was on the top line and in the larger font. 2023-01-17 10:53:37 No writing at all in between keys. 2023-01-17 10:54:21 The caveat to all of this is that I did mention double tapping a minute ago, so there has to be some convenient place to do that - if the whole panel was covered with key space it would be hard to double tap. 2023-01-17 10:54:49 I also want to be able to use Grafitti to write characters, so a place to start those strokes is required too. 2023-01-17 10:55:33 Most calculators have a gap between the "upper keys rows" and the "lower key rows" - that might suffice for both of these purposes. 2023-01-17 10:57:35 The display could also be a double-tap point, though it's kind of high up on the screen. It's not really good for grafitti, though, because some grafitti strokes start low and move high, and some start high and move low. So a "middle" starting point for that is preferable. 2023-01-17 11:02:50 Maybe a capacitive touch screen can differentiate between tap, double tap, and touch/slide without getting confused. If so then it might be ok to double tap on top of a key and not activate that key. Seems a little dicey, though. 2023-01-17 11:03:17 Well, distinguishing tap and doublel tap seems dicey. Touch slide is probably pretty easy to discriminate. 2023-01-17 11:05:12 I guess if I really am hot to explore this stuff the obvious way to do it is to just use a phone app. 2023-01-17 11:05:23 I mean for trying out user interface ideas. 2023-01-17 11:05:38 Awful lot of platform work gets "done for me" that way. 2023-01-17 11:05:52 Anybody here done any Android dev? I have no idea how hard it is to wade into. 2023-01-17 11:16:18 Well, this; 2023-01-17 11:16:20 https://linuxconfig.org/get-started-with-android-application-development-using-linux-and-android-sdk 2023-01-17 11:16:33 has instructions for installing a dev env called Android Studio. 2023-01-17 11:16:42 That went smoothly. 2023-01-17 11:58:01 Wow. 2023-01-17 11:58:20 Those "LCD keys" (keys with little built in screens) go for a bit over $40 a pop. 2023-01-17 11:58:22 :-) 2023-01-17 11:58:44 That would be a pricey calculator. I expected them to be prohibitively expensive - I was just curious as to how much so. 2023-01-17 12:11:52 Which forth do you suggest for linux and why is it better than dc, which is there by default? 2023-01-17 12:13:21 dc isn't really a Forth. It's a nice calculator, but it's hardly a complete Forth system. 2023-01-17 12:13:45 The "easy" answer here is gforth, just because it's pervasively available and very well known. 2023-01-17 12:13:47 gforth or pforth probably aren't terrible 2023-01-17 12:13:56 pforth is easy to build from source. 2023-01-17 12:14:18 Is there a forth implementation which can superse dc? I was disappointed because dc supports arbitrary number system and arbitrary precision while forth doesn't 2023-01-17 12:14:23 But I can't resist putting in a plug for "one that you write.' 2023-01-17 12:14:43 Right - Forth isn't a numerical analysis package. 2023-01-17 12:14:55 It's really oriented toward embedded system work, control, and so on. 2023-01-17 12:15:11 A standard Forth stack holds integers, which you can use as integers or addresses, or whatever you like. 2023-01-17 12:15:25 gforth offers some f loating p oint support, but not arbitrary precision. 2023-01-17 12:15:40 Are any well known linux softwares written in Forth? 2023-01-17 12:15:47 We were just talking here last night about the mpmath package in Python, which is an arbitrary precision package. 2023-01-17 12:16:21 If you wrote your own Forth you could set arbitrary precision floating point as a goal, and perhaps could use the same libraries Python uses for mpmath. 2023-01-17 12:16:50 One of the great things about Forth is that it's well within one programmer's reach to build one, even from assembly language. 2023-01-17 12:16:53 is pforth hard to build from source? 2023-01-17 12:17:01 No, it's easy. 2023-01-17 12:17:09 I did it, though it was over 20 years ago. 2023-01-17 12:17:26 So... it WAS easy. 2023-01-17 12:17:47 Easy to modify too - I adjusted it so its interface was over a network socket. 2023-01-17 12:18:29 Out of the box it has a non-standard console interface (doesn't put ok at the end of the line like common forth does). I modified that too. 2023-01-17 12:19:05 Hey guys - DM-41X is out for delivery today. Woo hoo! 2023-01-17 12:22:48 Can you show some simple programs or console sessions in pforth and gforth for comparison? 2023-01-17 12:23:18 they would look more or less the same 2023-01-17 12:24:12 Then how do I pick one? 2023-01-17 12:24:19 Try them out. 2023-01-17 12:24:24 Make a choice. 2023-01-17 12:24:29 It's a personal taste thing anyway. 2023-01-17 12:24:32 or flip a coin 2023-01-17 12:25:22 thrig is right - they're not going to feel that different insofar as actually using them goes. 2023-01-17 12:25:59 What OS are you running, Stalevar? 2023-01-17 12:26:53 because this sentence could be a totally valid forth program 2023-01-17 12:27:33 Slackware 2023-01-17 12:28:37 Oh, ok. I'm not really familiar with it. Are gforth and pforth both available in your package manager? 2023-01-17 12:28:53 I don't think they are 2023-01-17 12:29:13 Stalevar: there's a lot of differences in various forths. Some examples from mine are at https://retroforth.org/examples 2023-01-17 12:29:22 Ok. I can't remember the last time I used a Linux that didn't have gforth available, but I've stuck mostly with the major distros. 2023-01-17 12:29:31 (these will be noticable different from gforth or pforth) 2023-01-17 12:30:17 do I need unistd? 2023-01-17 12:30:58 is there forth for 8080? 2023-01-17 12:32:26 KipIngram: how did you implement nested words? 2023-01-17 12:32:41 are they kind of a dictionary? 2023-01-17 12:32:50 Stalevar: http://forth.org/eforth.html has links to a Forth for 8080 2023-01-17 12:33:01 in my case I have 3 kinds of words, builtin, colon and value words 2023-01-17 12:33:21 builtin are just functions, colon are arrays and value anything else 2023-01-17 12:33:33 but I think I want nested word definitions 2023-01-17 12:34:18 sometimes I refuse to factor a word for not having random words defined, if they're "local" to an already existing word there's no reason to not define them 2023-01-17 12:34:23 That's CP/M 2023-01-17 12:34:38 in my case I'll make those kind of words a hash xD 2023-01-17 12:35:34 and make : look for the name of a word, for example if it's a : word::nested ... ; word will become a hash if it's not already and nested a word inside that hash 2023-01-17 12:36:10 then I just need to add an else if to the function that executes words 2023-01-17 12:36:52 but I guess I won't allow multiple nesting 2023-01-17 12:37:03 like word::nested::more 2023-01-17 12:40:16 KipIngram, ok, pforth is tried out and found unworthy. typing ? and enter entails segmentation fault 2023-01-17 12:40:39 :-) 2023-01-17 12:40:41 Ooops. 2023-01-17 12:40:48 also mkdir build; cd build; cmake ..; make -j3 doesn't work 2023-01-17 12:40:49 Well, it's been a LONG time since I tried it. 2023-01-17 12:41:10 because it expects to be built from root source directory 2023-01-17 12:41:18 This is what i get from ? on gforth: 2023-01-17 12:41:20 Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc. 2023-01-17 12:41:20 instead of some other directory 2023-01-17 12:41:22 Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' 2023-01-17 12:41:24 Type `bye' to exit 2023-01-17 12:41:26 ? 2023-01-17 12:41:28 :1: Stack underflow 2023-01-17 12:41:30 >>>?<<< 2023-01-17 12:41:32 Backtrace: 2023-01-17 12:41:34 $7F7F7E816C70 @ 2023-01-17 12:41:45 That implies to me that ? is a word, but it expects something on the stack. 2023-01-17 12:42:01 Yes, but I thought it would give me some help 2023-01-17 12:42:07 because 'help' didn't work 2023-01-17 12:42:18 so pforth goes off my hd 2023-01-17 12:42:23 Well, "help" doesn't work either. 2023-01-17 12:42:33 Built in help isn't really a Forth thing. 2023-01-17 12:43:22 ? normally fetches a stored value and prints it 2023-01-17 12:43:29 Ah. 2023-01-17 12:43:37 Ok, so it expected an address on the stack. 2023-01-17 12:44:02 variable alpha ok 2023-01-17 12:44:04 27 alpha ! ok 2023-01-17 12:44:06 alpha ? 27 ok 2023-01-17 12:44:37 it's 15.6.1.0600 in the TOOLS wordset in ANS 2023-01-17 12:44:51 Stalevar, the usual recommendations here are the books Starting Forth and Thinking Forth. That and the gforth docs should get you along quite well. 2023-01-17 12:45:12 Both of those books can be found as pdf files online. 2023-01-17 12:45:19 If I know dc, I should be able to work with forth too, I think 2023-01-17 12:45:37 except I need list of basic commands with one line description 2023-01-17 12:45:51 I don't want to read an entire book, I just want a cheatsheet 2023-01-17 12:46:09 I would say no - dc is not a Forth. 2023-01-17 12:47:13 Stalevar: you can look at the word descriptions on the ANS standard of gforth documentation 2023-01-17 12:47:21 gforth gforth-fast gforth-itc gforthmi vmgen 2023-01-17 12:47:31 https://forth-standard.org/standard/words 2023-01-17 12:47:54 dc lets you create macros, but I don't know exactly how it does that. 2023-01-17 12:47:55 still some tutorial or alike to start should be nice 2023-01-17 12:48:44 also with gforth you can do a lot of stuff you couldn't in other forth implementations 2023-01-17 12:49:10 Well, Forth is simple to learn. There aren't many "rules." But there is at least a minor learning curve, and moreover, once you know all the mechanics it still takes work / practice to become a *good* Forth programmer. 2023-01-17 12:49:23 It involves a different mind set from other languages. 2023-01-17 12:49:25 like drawing a pixel :D 2023-01-17 12:49:39 https://rosettacode.org/wiki/Draw_a_pixel#Forth 2023-01-17 12:49:53 gforth-fast is faster, but doesn't support accurate backtrace on error, gforth-itc uses indirect threading IIRC 2023-01-17 12:50:10 Oh, don't get me started, vms14. It always annoys me how hard it is to turn on a little light on the screen from any Linux tool. 2023-01-17 12:50:35 KipIngram: well it's actually binding to c ffi 2023-01-17 12:50:38 Basically, most language environments give you a console, to which you can write characters. And doing anything beyond that involves some mountain of libraries. 2023-01-17 12:50:45 but it's a quite nice ffi 2023-01-17 12:50:53 I still miss the old days when just poking the right ram bit lit up a dot on the screen. 2023-01-17 12:50:56 c-function sdl-init SDL_Init n -- n 2023-01-17 12:51:06 the stack notation defines the types of parameters 2023-01-17 12:51:19 you may not miss the old days of having to reboot the entire system because you poked... poorly 2023-01-17 12:51:21 and that's all needed to make a binding 2023-01-17 12:51:58 thrig: if that happened (ok, when...) it was my own fault. 2023-01-17 12:52:48 I'm not sure about nested words 2023-01-17 12:52:59 but I wonder about several times 2023-01-17 12:53:30 vms14: You're really not aware of nesting in Forth. 2023-01-17 12:53:38 what nesting? 2023-01-17 12:53:47 When you create a new Forth word, it's a list of existing Forth words. 2023-01-17 12:53:53 KipIngram, in dc you just save a string in stack and can execute it at will, string is made by [ ] 2023-01-17 12:54:07 yeah, sorry I meant a word that lives inside another word 2023-01-17 12:54:15 a "local" word inside another 2023-01-17 12:54:15 Some of those words may be lists of other words, etc. etc., but you can't tell the difference once a word is built whether it's a primitive word or a higher level word. 2023-01-17 12:54:35 Well, unless you pick it apart and check. 2023-01-17 12:54:41 Operationally you can't tell the difference. 2023-01-17 12:54:46 and I guess you had that feature 2023-01-17 12:55:06 No, that's actually not a routine Forth feature. 2023-01-17 12:55:09 your : word allows nested definitions 2023-01-17 12:55:15 dc -e '1[p1+d10! No, not nested. 2023-01-17 12:55:24 It allows multiple entry points to a definition. 2023-01-17 12:55:35 This prints numbers from 1 to 10 2023-01-17 12:55:35 But I can't do this: 2023-01-17 12:55:44 : foo ... : bar ... ; ... ; 2023-01-17 12:55:51 Instead, I can do this: 2023-01-17 12:55:56 : foo ... : bar ... ; 2023-01-17 12:56:03 That is one definition with two entries. 2023-01-17 12:56:19 but bar would "exist" outside foo? 2023-01-17 12:56:24 Yes. 2023-01-17 12:56:37 They're both completely similar labels. 2023-01-17 12:56:43 They just point to different places in the code. 2023-01-17 12:56:51 then what's the difference between : foo ... ; : bar ... ; and : foo ... : bar ... ; 2023-01-17 12:56:58 For temporary names I'd do this: 2023-01-17 12:57:04 .: bar ... ; 2023-01-17 12:57:05 How do you print numbers from 1 to 10 in forth? 2023-01-17 12:57:11 : foo ... bar ... ; 2023-01-17 12:57:13 .wipe 2023-01-17 12:57:13 Stalevar: with LOOP 2023-01-17 12:57:24 can you write complete program? 2023-01-17 12:57:26 or BEGIN ... AGAIN 2023-01-17 12:57:27 dc -e '1[p1+d10! This is for dc 2023-01-17 12:57:31 10 0 do i . loop 2023-01-17 12:57:41 But that has to be compiled - it usually won't run from the interpreter. 2023-01-17 12:57:41 Stalevar: yeah, also with gforth you can use fancy libraries 2023-01-17 12:57:54 : print-em 0 do i . loop ; 2023-01-17 12:57:58 10 print-em 2023-01-17 12:58:02 10 0 do i . loop 2023-01-17 12:58:03 :1: Interpreting a compile-only word 2023-01-17 12:58:07 KipIngram: so .wipe does remove those temp words 2023-01-17 12:58:20 Yeah - any word defined using .: will get unlinked from the list. 2023-01-17 12:58:32 try: :noname 10 0 do i . loop ; execute 2023-01-17 12:58:35 .: is just like : except it sets a flag in the header. 2023-01-17 12:58:36 Stalevar: yeah some implementations allow it outside a definition, but not the one you're using 2023-01-17 12:58:46 .wipe unlinks all words with that flag set, through the entire dictionary. 2023-01-17 12:59:06 in most forth systems, flow control words are often only usable inside a definition 2023-01-17 12:59:08 but meh, it's almost the same as using forget 2023-01-17 12:59:09 Sometimes I might define a couple dozen 'helper words' with .:, just to eventually do one word with : 2023-01-17 12:59:15 My NUMBER is made that way. 2023-01-17 12:59:26 And then after I defined NUMBER I ran .wipe to get rid of all those helpers. 2023-01-17 12:59:42 then there's no difference between : foo : bar ; and : foo ; : bar ; ? 2023-01-17 12:59:45 Or rather to get them out of the dictionary - the *definitions* are still present and still get called. 2023-01-17 13:00:02 Yes, there's a difference. 2023-01-17 13:00:10 The first one has both labels pointing to the same s pot. 2023-01-17 13:00:15 The second one is two empty words. 2023-01-17 13:00:52 The first one compiles just one ; - the second one two. 2023-01-17 13:01:09 Your ; words are the only things that get compiled there. 2023-01-17 13:01:19 The :