00:00:00 --- log: started forth/10.06.22 01:12:11 --- join: warmana (~quassel@nat/ibm/x-dspgemfensgcakym) joined #forth 01:12:30 --- join: ktne (~ktne@unaffiliated/ktne) joined #forth 01:12:35 hello 01:14:16 --- quit: warmana (Client Quit) 01:14:23 what are the arguments for parser based control structures vs combinators+quotations? 01:15:03 factor uses combinators, older forths are using parser modifications to implement control structures 01:16:05 Pff! 01:16:11 Wait a bit, I have to digest it. 01:16:21 Quite unusual question for the channel. 01:16:37 hi ASau 01:17:18 Alright, I've understood your question. 01:17:26 The reason is as usual simplicity. 01:18:02 the question is, which one is simpler? 01:18:49 The whole advocacy is constructed around simplicity of implementation rather than general correctness. 01:19:01 i feel like combinators are simpler to implement if you have quotations but i find combinators harder to read 01:19:12 You have to implement quotations then. 01:19:39 Which isn't quite easy given memory allocation mechanism. 01:20:53 The way it is done, it takes a page of code (two or three "screens"), 01:21:21 you need GC? 01:21:48 You need either to allocate memory dynamically (perhaps, even PIC), 01:22:02 or to inline more jumps. 01:22:14 i'm not sure that i follow you 01:22:26 i have only a naive interpreter 01:22:32 no compiler yet 01:22:43 Have you looked how e.g. IF THEN is implemented in some classical system? 01:23:14 Basically, it reminds one-pass assembler. 01:23:29 not really, i assumed they just write a prologue for IF, add compiled code normall then some prologue for THEN, or what is after THEN? 01:23:46 Well... 01:24:07 You're studying CS, aren't you? 01:24:24 this is more of a hobby thing 01:24:35 Alright. 01:24:45 i know how C/C++ compilers work 01:24:46 Do you know how one-pass assembler works? 01:25:29 i might be able to implement on in one pass 01:25:38 not sure if that's the same way you are expecting 01:25:47 Alright. 01:26:00 read source, write code, keep a list of missing references, then at the end patch the code? 01:26:06 One-pass assembler uses this approach to resolve references: 01:26:25 all backward references are just inlined (obviously), 01:26:52 when you meet forward reference, you inline incomplete code 01:26:53 and remember position to inline the reference itself. 01:27:16 that's roughly what i thought about i guess 01:27:28 When you meet label to define, you check remembered references 01:27:33 yes 01:27:36 and inline them. 01:27:43 This is called "backpatching." 01:27:52 i see 01:27:55 IF THEN is implemented this very way: 01:28:22 (in classic systems) "IF" inlines ?BRANCH or 0BRANCH, 01:28:46 and/or uses >MARK to remember position. 01:29:10 "THEN" just takes the mark and closes the branch. 01:29:20 See >RESOLVE 01:29:43 i see, roughly what i thought too 01:29:47 BEGIN just puts mark on some "control stack" 01:30:12 WHILE is just "CS-SWAP IF", 01:30:41 AGAIN and UNTIL are just unconditional and conditional branches backwards. 01:30:46 right 01:30:53 REPEAT is just "AGAIN THEN" 01:31:33 Note, that everything is done using backpatching and some 01:31:33 manipulations with markers on control stack. 01:32:23 All memory allocation is straightforward: it's just "push pointer forward." 01:32:27 right 01:32:38 With quotations you have to do this: 01:32:59 remember allocation pointer or create scratch area, 01:33:14 compile new code (to scratch area, if this is the case), 01:33:50 recall allocation pointer, put jumps to flow around the quotation, 01:34:03 or finish the quotation in scratch area, 01:34:11 why can't you just push the quotation code inside the current code flow? 01:34:14 wait for combinator and use the quotation there. 01:34:25 Perhaps destroy the temporary quotation object. 01:34:28 put a jump in quotation prologue 01:34:39 to "jump over" to combinator 01:34:41 Yes, that's what I'm talking about. 01:35:02 ah, for a moment i thought that you mean allocating in a separate heap :) 01:35:08 Some people use it to mimic internal anonymous definitions, 01:35:14 but it's just not convenient. 01:35:37 Perhaps it isn't clear, but you can do both ways. 01:36:00 I'm trying to explain it at the same time, that clutters the whole explanation. 01:36:05 right 01:36:20 Both cases are just not convenient: 01:36:20 is there a trend to do quotations now? 01:36:38 you either have to play tricks with flow-around 01:36:51 or dynamically allocated and reallocated code. 01:37:22 Well... It is hard to learn any trends. 01:37:42 There's a trend to clutter the standard with random libraries. 01:37:50 :) 01:37:51 And that's the only trend you can observe. 01:38:24 i'm trying to decide on IF+THEN vs quotations 01:38:37 one advantage of quotations is that they are more generalist 01:38:51 If you're doing Forth, just go with backpatching. 01:39:00 You'll learn more. 01:39:08 And, no, quotations are not more general. 01:39:29 i mean, once you have quotations you can implement many other combinators more clearly, at least factor seems to do so 01:39:32 With backpatching you can do more complex things without 01:39:32 introducing other concepts. 01:40:05 E.g. "BEGIN ... WHILE ... WHILE ... UNTIL ... ELSE ... THEN ... THEN" loops. 01:40:26 Or "DO ... WHILE ... LOOP ... ELSE ... THEN" loops. 01:40:38 hmm 01:41:00 what exactly are they doing? it's like a multitude of combinators? 01:41:05 No. 01:41:11 In short it is this: 01:42:05 "BEGIN ( more? ) WHILE ( test ) WHILE ( next ) REPEAT ( found ) ELSE ( not found ) THEN" 01:43:14 i don't really understand the control flow that happens there but i think that i'm getting the point of it 01:43:19 "( last first ) DO ( test ) WHILE ( process ) LOOP ( processed ) ELSE ( failed ) UNLOOP THEN" 01:44:01 is there anything a quotations would do that a backpatching wouldn't? 01:44:37 What you call "quotation" is basically anonymous function. 01:44:59 yes 01:46:21 If you can create them only statically, then they are fully 01:46:22 equivalent to backpatching, only without memory allocation. 01:46:46 At least I can't imagine counter example right off top of my head. 01:47:12 i see 01:47:31 ok, i think i might do backpatching then 01:47:57 As such, you could just move them aside, label them, and use as regular words. 01:48:30 This is only more inconvenient, but it's just a matter of 01:48:31 style and convention rather than anything with deep theory 01:48:31 behind it. 01:48:53 Plus simplicity of implementation. 01:49:10 ok, thanks :) 01:52:11 AFAIR, you can look at implementation in the draft '94 standard. 01:52:29 Sample implementation, sure. 02:38:42 --- join: flash (flash@123.121.62.164) joined #forth 02:42:07 --- quit: foxes (Ping timeout: 252 seconds) 03:22:03 --- quit: flash (Ping timeout: 248 seconds) 03:49:19 --- join: foxes (flash@123.118.158.118) joined #forth 04:27:20 --- join: warmana (~quassel@nat/ibm/x-ryyncvrlfqfwueqp) joined #forth 04:28:46 --- quit: warmana (Client Quit) 04:42:31 --- join: malyn_ (~malyn@unaffiliated/malyn) joined #forth 04:44:17 --- quit: malyn (Read error: Connection reset by peer) 04:44:30 --- nick: malyn_ -> malyn 04:58:22 --- quit: gnomon (Ping timeout: 260 seconds) 04:58:41 --- join: gnomon (~gnomon@CPE0022158a8221-CM000f9f776f96.cpe.net.cable.rogers.com) joined #forth 06:06:02 --- quit: LionMadeOfLions (Ping timeout: 260 seconds) 06:06:39 --- join: LionMadeOfLions (~LionMadeO@70.114.156.242) joined #forth 07:58:15 --- quit: ASau (Quit: off) 08:06:30 --- quit: ktne (Ping timeout: 265 seconds) 08:12:47 --- quit: gnomon (Ping timeout: 265 seconds) 08:13:08 --- join: gnomon (~gnomon@CPE0022158a8221-CM000f9f776f96.cpe.net.cable.rogers.com) joined #forth 09:30:08 --- join: qFox (~C00K13S@5356B263.cable.casema.nl) joined #forth 09:33:00 --- join: ASau (~user@83.69.227.32) joined #forth 10:13:57 --- quit: ASau (Ping timeout: 245 seconds) 10:14:20 --- join: ASau (~user@83.69.227.32) joined #forth 10:37:17 --- quit: segher (Ping timeout: 260 seconds) 10:38:38 --- join: segher (~segher@84-105-60-153.cable.quicknet.nl) joined #forth 10:49:38 --- quit: crc (Ping timeout: 276 seconds) 10:50:59 --- join: crc (~charlesch@184.77.185.20) joined #forth 10:55:37 --- quit: crc (Ping timeout: 245 seconds) 10:57:47 --- join: crc (~charlesch@184.77.185.20) joined #forth 13:42:47 --- join: Snoopy_1711 (Snoopy_161@dslb-088-069-153-190.pools.arcor-ip.net) joined #forth 13:45:07 --- quit: Snoopy_1611 (Ping timeout: 260 seconds) 13:54:38 --- quit: qFox (Read error: Connection reset by peer) 13:57:04 --- nick: Snoopy_1711 -> Snoopy_1611 17:44:07 --- quit: Snoopy_1611 () 17:45:49 --- join: Snoopy_1611 (Snoopy_161@dslb-088-069-130-137.pools.arcor-ip.net) joined #forth 17:59:39 --- quit: gnomon (Ping timeout: 240 seconds) 17:59:58 --- join: gnomon (~gnomon@CPE0022158a8221-CM000f9f776f96.cpe.net.cable.rogers.com) joined #forth 18:19:12 --- quit: Snoopy_1611 () 21:02:22 --- quit: yiyus (Ping timeout: 272 seconds) 21:20:10 --- join: yiyus (~124271242@je.je.je) joined #forth 21:35:55 --- quit: crc (Ping timeout: 240 seconds) 21:36:55 --- join: crc (~charlesch@184.77.185.20) joined #forth 22:41:33 --- quit: ASau (Quit: off) 23:36:13 --- join: ASau (~user@77.246.231.164) joined #forth 23:59:59 --- log: ended forth/10.06.22