2024-04-12 00:32:48 what is the forth equivalent of haskell's 3arg (2arg (1arg x) y) z (4arg a b c d) ? 2024-04-12 00:33:18 1arg 2arg 3arg and 4arg are n-argument functions. a b c d x y z are values that these functions are applied to 2024-04-12 00:36:43 a b c d 4arg or maybe d b c a 4args or any other stack order you want, depending on the forth, etc 2024-04-12 00:40:22 d c b a 4arg z y x 1arg 2arg 3arg 2024-04-12 01:04:28 is it possible to have a forth that has partial application? and higher order functions? 2024-04-12 01:04:41 well i've seen fold and map in forth 2024-04-12 01:04:46 but not partial application 2024-04-12 01:06:48 it might be a Joy to see something like that 2024-04-12 01:06:57 ... 2024-04-12 01:08:49 : 2+ ( x -- x+2) 2 + ; ( partial application) 2024-04-12 01:21:55 what would that look like in haskell 2024-04-12 01:22:09 i'm kind of lost on how to read this so far 2024-04-12 01:25:25 add2 x = (+) 2 i think? not sure that's how to do it with the infix +, i've only played around with haskell a little and it was a long time ago 2024-04-12 01:26:04 haskell yelled at me about type errors for a while, and then I uninstalled it 2024-04-12 01:28:04 i lost interest the moment they turned tabs into compile errors 2024-04-12 01:33:08 zelgomer: yeah but what would that whole code look like? i don't know how to read it : 2+ ( x -- x+2) 2 + ; ( partial application) 2024-04-12 01:33:25 or feel free to use python or js 2024-04-12 01:34:29 um 2024-04-12 01:35:29 read it as "define a new word called '2+' which adds 2 to the number on the top of the stack" 2024-04-12 01:36:07 hmm 2024-04-12 01:36:07 or more fundamentally, "define a new word called '2+' which pushes the literal numeric value '2' onto the stack and then calls the word '+' and then exits" 2024-04-12 01:36:15 and what does the ( x -- x+2) bit mean? 2024-04-12 01:36:20 that's a comment 2024-04-12 01:36:30 ok 2024-04-12 01:36:39 what does the comment mean? 2024-04-12 01:37:45 it's conventional to annotate your forth words with their effects. it means this word expects for one item to be on the the stack and when it returns, it will leave that item with 2 added to it 2024-04-12 01:38:23 is the "--" like haskell's "->" ? 2024-04-12 01:38:46 this is very specific to this example. in general you'll usually see something more ambiguous, like ( x1 -- x2) or ( a -- b), which means "pops one item and pushes something else" 2024-04-12 01:39:11 what does haskell's -> do again? 2024-04-12 01:40:36 cheater: i'm happy to answer questions, but if this is level you're at, i strongly recommend start with some reading material. google leo brodie's "starting forth", for one example. there's a version of it available for free online 2024-04-12 01:42:32 and then tell me what movie i should watch tonight 2024-04-12 03:11:08 cheater: the -- in the comment is just text that separates the representation of what the word uses and what it leaves. Forth doesn't care about what's in the comment. 2024-04-12 03:11:19 It's not like the -> in haskell, which does have actual meaning in that language. 2024-04-12 07:45:06 cool 2024-04-12 17:26:03 KipIngram: I have the same impression when I hear 'token' in Forth context, of token threading 2024-04-12 17:47:48 https://www.youtube.com/watch?v=ApYGMzPgzuo 2024-04-12 17:48:21 veltas: Yeah, I don't know if my definition is strictly correct, but it seems to have gotten me by so far. 2024-04-12 17:48:50 I used to just assume that type of system ("token" threading) would be inherently slow, but I've started to think better of it recently. 2024-04-12 22:38:30 KipIngram: I think it's probably a bit slower but not enough to avoid using it if space is the main constraint 2024-04-12 22:38:52 zenv builds tokenised by default, can flip a switch between DTC and tokenised