2024-06-03 01:11:57 I'm trying really hard 2024-06-03 01:12:00 to turn this into the comments: 2024-06-03 01:12:02 enum: Color Green Red Yellow ;enum 2024-06-03 01:12:04 \ 0 constant Color.Green 2024-06-03 01:12:06 \ 1 constant Color.Red 2024-06-03 01:12:08 \ 2 constant Color.Yellow 2024-06-03 01:12:10 \ 3 constant Color.# 2024-06-03 01:41:56 I give up for today 2024-06-03 01:45:10 me too, bud 2024-06-03 01:45:12 #metoo 2024-06-03 08:44:34 lf94: You'll probably need to parse the words, put them in a buffer somewhere and EVALUATE them as 'constant .' 2024-06-03 08:49:44 A simple state machine is a case statement inside an infinite loop for any language. 2024-06-03 08:55:51 lf94: Conventionally you'd just call CONSTANT in your word and write out the prefixed names, no normal forth defining words add a prefix automatically 2024-06-03 08:56:16 Like FIELD: for instance just defines a word with the given name 2024-06-03 08:58:00 e.g. : ENUM: DUP CONSTANT 1+ ; 0 ENUM: COLOR.GREEN ENUM: COLOR.RED ENUM: COLOR.YELLOW ENUM: COLOR.# DROP 2024-06-03 08:59:47 Better names in context of the program would be: GREEN RED YELLOW #COLORS 2024-06-03 09:00:03 Because, duh, GREEN is a color! 2024-06-03 09:09:14 KipIngram: Remember in chuck's POL paper he talks about routines vs subroutines 2024-06-03 09:09:26 A state machine is easy to get right with routines 2024-06-03 09:18:35 The second-best is a loop executing a variable's xt 2024-06-03 09:19:38 So e.g. VARIABLE NEXT-STATE : MACHINE FIRST NEXT-STATE ! BEGIN NEXT-STATE @ EXECUTE AGAIN ; 2024-06-03 09:21:23 ['] FIRST I should say 2024-06-03 09:21:33 The switch statement is the compromise that came from languages that don't have vectorised execution, but in Forth and even C that's not a problem, so you shouldn't be using a switch 2024-06-03 09:27:33 Could use defer for this too 2024-06-03 09:28:36 DEFER NEXT-STATE : MACHINE ['] FIRST IS NEXT-STATE BEGIN NEXT-STATE AGAIN ; 2024-06-03 09:28:53 I don't really know if that's legit but I guess it would work on most forths 2024-06-03 09:55:41 For the way my brain works a switch statement is clearer.  One can always optimise later if you run into performance issues.  Coding a machine with:  StartMachine, addState is possible but for me way more complex. 2024-06-03 09:58:25 Coding a traffic light is a very nice way to learn how a state machine works. 2024-06-03 10:11:03 In the problem I think you can encode all the state in one field. It might be easier to split them up anyway. 2024-06-03 10:11:22 I definitely would represent traffic with one field, with a bit assigned to north traffic and east traffic each 2024-06-03 10:12:20 And in the transition function you then check: TRAFFIC EAST-TRAFFIC AND and TRAFFIC EAST-TRAFFIC = in the relevant conditions 2024-06-03 10:13:27 A lot of these kinds of groups of boolean ideas work a lot easier if you just use bitwise logic, which the machine is good at anyway, and for which there's good support in all Forths 2024-06-03 10:14:17 Combining colors into one field means you can do a CASE statement on the combined colors 2024-06-03 10:14:51 e.g. 0 CONSTANT GREEN 1 CONSTANT RED 2 CONSTANT YELLOW : COLORS ( c1 c2 -- c) 2 LSHIFT OR ; 2024-06-03 10:17:46 : TRANSITION ( c t -- c) TUCK SWAP CASE GREEN RED COLORS OF EAST-TRAFFIC AND IF CLEAR-NS YELLOW OR THEN ENDOF .... etc 2024-06-03 10:36:17 lf94, skvery: https://termbin.com/3t29 2024-06-03 10:36:51 Well LIGHTS is wrong because there's no word to get next traffic state 2024-06-03 10:37:26 But you get idea 2024-06-03 10:41:48 wow this is an incredible work https://www.youtube.com/watch?v=0PclgBd6_Zs 2024-06-03 12:10:21 Don't write C++ like Rust, don't write C like C++, don't like Forth like C. 2024-06-03 12:10:31 don't write* Forht 2024-06-03 12:11:35 Yea, don't write forth haha 2024-06-03 12:11:44 jk 2024-06-03 12:12:05 btw thanks for the tip earlier about simplifying some expressions by factoring out words, it worked 2024-06-03 12:12:14 But I still have to implement dictionary chaining for my tiny DSL 2024-06-03 12:14:16 olle: Maybe WORDLIST / FIND will do? 2024-06-03 12:15:03 Don't think so, some parts of the DSL evaluate to a string, other parts actually do the calculation 2024-06-03 12:15:22 So + is sometimes and operation, other times returns a string 2024-06-03 12:15:25 an* 2024-06-03 12:16:00 Allow parsing and do like S" maybe 2024-06-03 12:19:39 Yea, but then I need to filter the inside of the string :) If it's raw SQL. 2024-06-03 12:19:55 The benefit of DSL would be to allow only certain operation, so there's already a safe subset of SQL, PHP, etc 2024-06-03 12:20:28 I mean S" for parsing a string literal, not to encapsulate the expression 2024-06-03 12:21:38 Aha 2024-06-03 12:23:06 >some parts of the DSL evaluate to a string, other parts actually do the calculation 2024-06-03 12:23:14 Does this mean more like constant folding? 2024-06-03 12:23:34 So + might literally do plus 'right now', and in some cases + is passed to SQL query? 2024-06-03 12:23:52 Yep 2024-06-03 12:24:19 There's a syntax for this in Forth, [ and ] allow you to disable compilation temporarily 2024-06-03 12:24:21 The part of the DSL that happens inside PHP evaluates + as an expression right now, but SQL evaluates to a string that's passed to the database. 2024-06-03 12:24:28 Oh yea! 2024-06-03 12:24:52 Hm hm 2024-06-03 12:25:29 So if you want to fold a constant you can do: : MY-FIELD [ PLACE OFFSET + ] LITERAL ; 2024-06-03 12:25:50 You can reuse [ and ] words and define new behaviour like swapping the top wordlist 2024-06-03 12:25:59 I can look into it, have to do "normal" work right now :( 2024-06-03 12:26:21 Terrible, having to actually be productive :P 2024-06-03 12:26:27 I writing my own tiny Forth environment inside PHP btw, because that's the server host language. 2024-06-03 12:26:31 It sucks :( 2024-06-03 12:26:57 I did the `:` word yesterday, was not that hard. 2024-06-03 12:28:08 As fun as this is, if someone did this at work I would probably complain at them :P 2024-06-03 12:28:39 Yea this project, to make a report generating DSL, is not green lit 2024-06-03 12:28:48 Like 'what the f*** did you do this for' 2024-06-03 12:29:02 Hehehe 2024-06-03 12:29:19 There is one big benefit tho - release a new report WITHOUT needed a new deployment of the software 2024-06-03 12:29:33 And customize reports per customer. Dunno if needed/wanted yet. 2024-06-03 12:29:40 Probably cheaper ways to achieve that 2024-06-03 12:30:42 Also the cost you've associated with 'deployment' suggests process issues 2024-06-03 12:30:51 Sever process issues, yes 2024-06-03 12:31:09 Cheaper why, a DSL is a pretty simple thing to do 2024-06-03 12:31:23 ACTION lunch 2024-06-03 12:33:55 If I saw the queries people actually use I would probably be able to define a simple subset that doesn't need full expressions 2024-06-03 12:37:31 Even if expressions are needed I would probably parse to AST in javascript and send something dumb back to PHP in a format it understands but won't be a security risk 2024-06-03 12:44:34 The DSL scripts should be saved in db tho, to be able to have a per-customer system 2024-06-03 12:45:00 And they might need to be changed by non-customers, by changing the db values 2024-06-03 12:46:45 Well the more sophisticated this sounds, the more it seems like you should use an existing language and just tighten the security another way 2024-06-03 12:47:16 Because the aim here is to allow queries with some security consideration, otherwise we'd just let them send raw queries 2024-06-03 12:47:35 There are probably better ways to control access 2024-06-03 12:51:22 It's not only queries, it's also CSS, PHP, potentially JavaScript 2024-06-03 12:51:43 And multiple export formats - HTML, CSV, something called SIE4 but that might be harder to do in the DSL 2024-06-03 15:48:18 This is quite good coverage if you're interest in quantum stuff: 2024-06-03 15:48:20 https://www.youtube.com/playlist?list=PLRN3HroZGu2mCtdalEmZAM2nr1xBWAtUn 2024-06-03 15:56:27 Bah, modern physics 2024-06-03 15:56:46 PBS is good too btw 2024-06-03 15:56:50 And Crash Course 2024-06-03 16:37:34 could be worse, could be post-modern physics 2024-06-03 16:38:17 Hehehe 2024-06-03 16:38:34 It's already confusing enough eh 2024-06-03 16:59:59 Oh, PBS Spacetime in particular is great. I've enjoyed it a lot since they replaced the guy who yelled all the time with the current guy - he's got such a pleasant, soothing voice - totally stark contrast to the old guy. 2024-06-03 17:06:32 They sometimes push the Many Worlds interpretation a bit harder than I care for. But it's easy enough to overlook. 2024-06-03 17:06:53 I like Sabine Hossenfelder too. 2024-06-03 17:08:50 The link I posted above is a bit different, though - it's not what I'd call "popular science communication." It's an actual univerisity caliber course. In depth. 2024-06-03 17:09:15 I particularly like how well he's tying the development to the experimental history of the field. 2024-06-03 17:42:03 my Forth is at 1378 words! 2024-06-03 17:58:45 :-) 2024-06-03 17:59:14 How many primitives? 2024-06-03 18:31:11 1378 2024-06-03 18:31:12 lol 2024-06-03 18:39:13 that sounds like a lot 2024-06-03 18:45:42 gforth 0.7.3 has 1840 findable words by default 2024-06-03 18:46:29 I think a few hundred is more normal for a simple forth, but 1378 isn't crazy depending on what it's for 2024-06-03 18:46:54 /why/ 2024-06-03 18:47:12 Well what if it was a full OS 2024-06-03 18:47:17 That would be more reasonable then right 2024-06-03 18:47:46 but we're not talking about a full os, we're talking about core primitives 2024-06-03 18:48:05 I'm assuming they've just programmed them all in assembly or some high level language 2024-06-03 18:48:13 So because they're allergic to colon words 2024-06-03 18:48:49 Probably get better performance that way 2024-06-03 18:49:36 just counted mine, currently at 151 and could probably stand to lose a few 2024-06-03 18:50:21 ANS has about 350 words, and Common LISP about 950 2024-06-03 18:50:59 thrig: If you write an ANS Forth you usually need more words than the standard ones to factor it at all 2024-06-03 18:51:09 Sorry didn't mean to @ you 2024-06-03 19:08:43 Re the 'I2C is simple' claim https://stackoverflow.com/a/61623107 2024-06-03 19:09:38 There is no agreement on whether I2C addresses should be written shifted or unshifted 2024-06-03 19:10:25 'Annoying detail no. 2134 of I2C-in-practice' 2024-06-03 19:13:12 ah yes, even i've encountered that one 2024-06-03 19:13:33 addresses in the data sheet are often half the address linux wants (or twice? i forget now) 2024-06-03 23:45:38 w o r d z 2024-06-03 23:55:25 : microsoft ;