00:00:00 --- log: started forth/06.11.23 00:10:34 --- join: neceve (n=claudiu@unaffiliated/neceve) joined #forth 00:29:11 --- join: Cheery (n=Cheery@a81-197-54-146.elisa-laajakaista.fi) joined #forth 01:36:45 --- join: zpg (n=user@user-514d7663.l2.c2.dsl.pol.co.uk) joined #forth 01:48:24 How does the gForth FFI work? 01:57:32 What do you mean? Are you looking for an example? 02:07:19 hi guys 02:07:24 Hi zpg 02:07:39 Razor-X: http://ezil.sourceforge.net/latest/gtk.html 02:07:46 Razor-X: that's the FFI for GTK bindings 02:07:49 hi Quartus 02:51:27 --- join: vatic (n=chatzill@pool-162-84-178-20.ny5030.east.verizon.net) joined #forth 05:00:35 happy turkey day! 06:07:58 erdier: gobble! gobble! 06:11:38 --- part: matju left #forth 06:25:06 --- quit: vatic ("*poof*") 07:17:18 Quartus: Yeah an example. And sorry for the horribly late reply. 07:17:27 And yeah, Happy Turkey Day everyone :) 07:19:00 Razor-X: I think there was an example posted 08:01:19 erider: Yup. 08:01:31 Just clarifying :) 08:03:52 :) 08:04:48 --- quit: crest_ (Read error: 60 (Operation timed out)) 08:30:51 --- join: iano (n=iosgood@63.105.26.46) joined #forth 08:31:54 --- quit: iano (Client Quit) 08:56:01 --- join: crest_ (n=crest@p54897785.dip.t-dialin.net) joined #forth 09:20:38 --- join: jackokring (n=jackokri@static-195-248-105-144.adsl.hotchilli.net) joined #forth 09:25:37 --- nick: crest_ -> Crest 09:37:13 hi 09:38:01 hey 09:38:11 howdy Quartus 09:38:20 how's it going? still puppeteering? 09:38:51 Indeed. Had a delay but I'm back to Servo building. 09:39:07 good stuff. popping down for some coffee, shall be back shortly. 09:39:14 i'm keen to know how the book's going. 09:39:27 It's ongoing as well. 09:48:38 happy turkey day! 10:02:10 rehowdy 10:06:06 It transpires that COMPARE outshines my STR< that I just wrote on the Palm. Yet another occasion of writing something that's already in the base language. 10:07:09 heh 10:07:50 No biggy I guess. 10:07:56 though my definition was c. 15-20 words long. 10:08:41 --- join: matju (n=matju@70.55.165.49) joined #forth 10:11:47 Tjat 10:11:50 That's pretty long. 10:11:59 yep 10:12:36 i have a few words dedicated to str=, and length comparison 10:13:03 then a do loop that compares two addresses, if A is less than B, it calls char-pair+, else it leaves the loop. then there's a bit of cleanup code to get the relevant flag. 10:13:05 two ifs 10:24:16 Can probably be factored. That pattern-matching code has a compare implementation you could reference. 10:51:47 --- join: virl (n=virl@chello062178085149.1.12.vie.surfer.at) joined #forth 10:52:35 It has a small extension for pattern-characters, but you can figure that out I'm sure. 10:54:54 --- join: marble (n=glass@cpc1-bolt6-0-0-cust18.manc.cable.ntl.com) joined #forth 10:55:13 --- join: Snoopy42_ (i=snoopy_1@dslb-084-058-179-076.pools.arcor-ip.net) joined #forth 11:03:21 --- quit: Snoopy42 (Read error: 145 (Connection timed out)) 11:03:29 --- nick: Snoopy42_ -> Snoopy42 11:11:33 --- join: ttuttle (n=tom@unaffiliated/ttuttle) joined #forth 11:11:38 Quartus: Happy Thanksgiving! 11:11:50 ttuttle, thanks -- but ours was in early October. :) 11:11:53 Quartus: ;-) 11:12:01 Quartus: Hey, did you hear that Amazon.com is down? 11:12:15 I didn't. 11:12:30 Quartus: They were selling 1000 Xbox 360's for $100, and they got DDoSed by everyone trying to buy them. 11:12:37 Funny. 11:12:50 Quartus: Yeah. It's mind-blowing. They're supposed to be bulletproof. 11:13:01 What with all those innovative patents and what-not. 11:13:02 Quartus: I'm wondering if maybe they did this on purpose as a stress test/DDoS drill... 11:13:05 Quartus: Yeah. 11:13:16 I doubt they'd plan for a public embarassment. 11:13:54 I briefly thought about buying a 360 just to play Rising Dead, but they're too expensive for a toy that'd waste that much of my time. :) 11:14:38 Quartus: Public embarrassment? They'd have a good excuse, at least. 11:14:43 Quartus: They're back up, at least for a bit. 11:15:10 Yes, if you put a 'sale' sign on your front door, and your floor collapses under the weight of the customers, that's a public embarassment. 11:16:44 Quartus: That's true. 11:16:56 Quartus: But at least it makes a good story. 11:17:11 "Amazon can't keep their site running under load"? Good story for the competition. 11:23:06 re 11:24:01 No, I meant for their customers. 11:24:13 It makes a good analogy to retail stores. 11:26:40 --- quit: ttuttle ("leaving") 11:37:25 Hmmm. Is there anything like working with signed chars in Forth? 11:37:36 Because C! and C@ seem to be unsigned. 11:39:36 hi 11:39:52 Razor-X: howso? 11:42:21 --- quit: neceve (Remote closed the connection) 11:42:54 zpg: Storing -1 using C! gives you 255 on C@. 11:43:46 indeed, that makes ss 11:43:59 *sense. why would you want signed characters? 11:44:15 For a reason. But I guess it is outlandish. 11:44:23 Oh well, I can write it myself. 11:44:29 what's the reason? 11:44:38 I want to do a little delta encoding test. 11:44:42 a character is clearly 8-bit. 0-255 all have the relevant mappings. 11:45:10 True. 11:46:00 what advantage would signed words provide? after all, what would -1 mean in an 8-bit lookup table? 11:46:16 There's no actual advantage. 11:46:25 (Which I see now.) 11:46:31 heh, k. 11:46:38 This is just something I'm doing to play around with Forth. Heh. 11:46:57 i can appreciate that. 11:52:56 back later 11:52:59 --- quit: zpg ("ERC Version 5.1.3 (IRC client for Emacs)") 11:58:11 write your own char sign-extend. 12:06:23 --- quit: erider (Read error: 110 (Connection timed out)) 12:07:06 --- join: erider (n=erider@unaffiliated/erider) joined #forth 14:08:05 --- quit: Cheery ("Download Gaim: http://gaim.sourceforge.net/") 14:21:51 random forth question -- where are the stacks and the dictionary located in memory? 14:22:43 is it possible to run out of in, say, the dictionary despite still having a lot of free memory? 15:00:55 this depends on your implementation 15:01:33 in old implementations the dictionary grows form lower memory to higher and stacks grow down from higher to lower 15:01:46 are the stacks interleaved, or something? 15:02:18 no their are just continous blocks of memory addressed as stack in most implementation 15:02:21 s 15:02:50 but modern implementations protected dictionary and stacks before each other 15:02:58 *protect 15:04:25 before each other? before=from? 15:04:34 from each other 15:05:19 sry atm i'm chatting 2 languages and i just forget to change from german to english gramma 15:05:31 *in 2 langs 15:05:44 no worries, I'm still following along reasonably well :) 15:06:03 ;) 15:08:01 but normaly you don't have to worry about stacks growing into eachother or the heap/dictionary 15:08:14 you mean from a pragmatic point of view? 15:08:36 unless your're heavly using recrusion 15:09:05 all the same, one of the stacks probably has a hardwired upper limit on it's size... 15:09:15 ans forth defines iirc at least 64 elements per stack 15:09:26 * marble acks 15:10:12 forth cpus not intended for the ultra cost sensitiv market provide stack under and overflow interrupts 15:10:41 these allow the implementation of arbatary size stacks 15:12:17 I was thinking that if one had a virtual memory scheme, one could trigger an interrupt when a stack grew into it -- allowing one to shuffle the stacks around in memory... 15:12:43 others like the b16 limit the stack depth to much less than 64 cells 15:13:00 --- join: Snoopy42_ (i=snoopy_1@dslb-084-058-179-076.pools.arcor-ip.net) joined #forth 15:13:16 oooh my transistor buget makes a $1000 tamagotchi possible ;) 15:13:45 a fixed size stack is the easy thing to implement... 15:14:16 marble: it would be more performant to place the stacks far away from anything other in the virtual addressspace so you don't have to remap them ever 15:15:06 with 32-bit addressing, this sounds reasonable 15:15:32 and with 16 bit addressing you normaly don't have a pmmu 15:15:49 jackokring: you have a transistor budget? what kinds of things to you work on? 15:16:52 http://indi.microfpga.com bsd licence open IP cores, make one if you have fabrication of IC facilities 15:17:14 44 pin and free 15:17:52 --- quit: Snoopy42 (Read error: 145 (Connection timed out)) 15:17:59 --- nick: Snoopy42_ -> Snoopy42 15:18:21 can gcc target it? 15:18:55 if you modify gcc yes, but this is not done as yet, as i have not done it 15:19:01 feel free 15:20:51 full ISA is very simple 15:21:50 Instruction Set ??? 15:22:05 if you make a C for it, i will link to your site 15:22:18 Architecture 15:22:43 add, and, xor, load 15:26:54 --- part: matju left #forth 15:31:31 say, how much energy does it take to maintain processor s-ram state ? 15:33:11 * marble likes the notion of uber-low-power asynchronous processors 15:35:47 it's pretty small with 4 registers 15:39:22 It's bad Forth style to use the stack that much. 15:39:35 --- join: nighty (n=nighty@sushi.rural-networks.com) joined #forth 15:41:09 But if you have a recursive function... 15:43:01 I'm will to accept the pragmatic argument that heavy use of the stack suggests poor forth style 15:43:23 Use stack acrobatics. 15:43:44 You also have the return stack and memory ``here'' if you need it. 15:50:36 say, is there a list of immediate words somewhere? 15:51:30 --- quit: jackokring (Read error: 110 (Connection timed out)) 15:51:53 I'm wondering if all immediate words concern themselves with control-flow... 16:05:38 ( and \ 16:07:24 cute :) -- : #! postpone \ ; immediate 16:09:47 Hey 16:09:56 No, all immediate words do not concern themselves with control-flow. 16:10:08 lo Quartus 16:12:13 ~130 immediates in gforth 16:12:44 Control-flow is a small handful of words. 16:15:36 endcase endof of case endtry (recover?) try [while] [again] [repeat] [until] [begin] [next] [for] [loop] [+loop] [?do] [do] [endif] [then] [else] [ifundef] [ifdef] [if] ?exit exit ... 16:16:07 Many of those are just implementation factors. 16:17:18 The [] words are Gforth's interpretation versions of compile-only words, which I personally think are silly, but there they are. You won't find [do] [loop] in too many systems. 16:17:21 the 2 categories of immediate words I can identify atm are: (1) control-flow words (2) parsing words 16:17:56 Quartus: true enough -- pforth, pfe, and kforth don't have them... 16:18:23 Control-flow words, parsing words, and any other word that has to take special action at compile time. 16:19:01 ; literal sliteral etc. 16:20:34 I don't understand too many forth words let -- what does literal do? 16:20:52 Compiles a literal value. : foo [ 42 ] literal ; foo . -> 42 16:21:04 Equivalent to : foo 42 ; 16:21:31 It's not forward-parsing, and it's not control-flow. 16:21:45 [ is also immediate. 16:21:47 and we need it because stuff that [ ... ] leaves stuff on the stack aren't automagically compiled into the definition? 16:22:20 That was just an example... it could as easily have been 42 constant bar immediate : foo bar literal ; foo . -> 42 16:22:33 Which would be equivalent to 42 constant bar : foo bar ; 16:22:48 same difference :) 16:23:22 literal takes a value from the stack and compiles it into a definition, no matter how the value gets on the stack -- placed there after [ or by another word. 16:29:16 are there any forths that wouldn't get screwed up if we left 42 on the stack? I'm imagining the compiler makes use of the stack... 16:29:28 Pretty much all of them would. You have to keep the stack balanced. 16:29:48 Any decent system will report the imbalance. 16:30:09 : foo [ 42 ] ; reports 'unstructured' in Gforth. 16:30:17 it does :) 16:30:41 With my ANS layer, retroforth reports "Exception: control structure mismatch" 16:31:25 F-PC reports 'Stack Changed', which is very odd. 16:32:01 But at any rate, it's a message. 16:33:08 Virtually every existing standard system uses the data stack as the control-flow stack during compilation; it's not required, but it's simple and straightforward, and there's no practical advantage to not so doing. 16:33:17 [ 42 literal ] also works... 16:33:26 [ 42 literal ] will work on some systems and not on others. 16:33:35 hmmm... 16:33:45 [ 42 ] literal is the version that will consistently work. 16:34:15 Or, as is the more common practice, [ 3 5 * ] literal (or some other calculation, usually involving predefined constants or variables) 16:35:44 why might [ 42 literal ] fail ? 16:35:58 : meow [ : dog [ 1 ] literal ; ] ; 16:36:10 defined dog, but didn't define meow :) 16:36:37 [ 42 literal ] is not warranted to work, as you're working with literal outside of compilation state, and literal has undefined interpretation semantics. 16:36:42 You also cannot nest definitions in a standard forth. 16:37:02 That is, there may be standard systems in which it works, but the behaviour is not guaranteed in any way. 16:37:55 Bear in mind that [ and ] are not syntactic markers. They are words, functions that do something specific. 16:37:59 sounds like lack of reentrancy/global state... 16:38:05 Likewise : and ; are not syntactic markers either. 16:38:15 I gathered all that :) 16:38:29 I have been doing a little reading over the last few days ;) 16:38:49 [ and ] are not required to nest. It isn't that it's especially hard to implement, it simply isn't a requirement of a standard Forth, and in fact it offers little or no practical advantage while significantly complicating the compiler. 17:08:00 Forth .NET is pretty cool! 17:09:15 hey erider, new toy? 17:10:35 There's a Forth .NET? 17:10:54 yes 17:11:04 hi marble 17:11:11 hi Razor-X 17:11:20 Heya erider. 17:12:38 Razor-X: the .NET forth is called DeltaForth 17:12:59 Oh. 17:13:09 its a compiler 17:13:25 for .NET framework 17:13:50 works on linux with mono 17:20:55 * marble observes that (-comments can't be nested 17:25:39 ( hello))) throws an exception in my gforth... 17:26:37 Yeah, I realized that too. 17:30:17 ( hello)) works, buts ( hello))) doesn't -- that's because there's a ), but there isn't a )) in my dictionary 17:32:57 ( hello)." meow" 17:34:27 hmm 17:36:23 doesn't give me a warm fuzzy feeling 17:36:56 marble: do you need nested 17:37:16 I'm just exploring, is all 17:37:37 ah 17:37:45 no doubt, if one ever machine generated some forth code (a silly idea, I know) one could trip over this 17:38:10 er.. ignore my last comment :) 17:38:49 ok :) 17:41:55 marble are you making progress with forth? 17:43:04 I know what POSTPONE and IMMEDIATE mean :) 17:43:41 what? 17:44:37 postpone means ignore the immediate bit 17:45:03 immediate means mark the last compiled word as immediate 17:45:45 if something is marked as immediate, it get's done as soon as it's read by the interpreter/compiler 17:46:12 I know what the text interpreter and the address interpreter are 17:47:02 marble: cool! 17:47:03 "address interpreter" is a term applicable only to a certain kind of implementation of Forth, and rather dated one at that. 17:47:14 I'm glad you are getting it 17:47:21 I'm not completely 17:47:23 POSTPONE does not mean "ignore the immediate bit". 17:48:14 you can't postpone 1 ;.; 17:48:27 You cannot POSTPONE a literal value. You can POSTPONE non-immediate words. 17:49:31 ah, well -- in practical terms, my understanding would have served my well for a short while :) 17:49:36 *me 17:50:15 Bad idea to start out with the wrong understanding. It isn't a good idea to boil every new concept down to a sound-bite; you'll ingrain wrong ideas. 17:50:31 you have to start with approximations 17:50:41 you didn't start out know forth when you were born ;) 17:51:08 You can start out with the actual facts, they're available. No need to convert them into something shorter, but incorrect. 17:51:26 hi Quartus 17:51:30 Hi erider 17:51:44 were you taught the I before E rule ? 17:52:06 were you taught about electron shells ? 17:52:28 I have found a .NET forth compiler which is pretty neat 17:52:46 Both sets of rules apply generally, but not specifically. Your generalization was simply wrong; the actual facts are not any larger than your generalization, and are right. It's not the same thing. 17:53:32 both rules are wrong -- they work well enough, but fail in certin cases 17:54:24 Your generalization does not work well enough; it fails in every case. POSTPONE does not mean 'ignore the immediate bit'. That's just wrong. I'm correcting you for your benefit, but also because you're stating this stuff as fact, and it goes into the log, and that turns up in google searches, so somebody else might take your wrong restatement as fact. 17:55:21 Quartus: you should have just called it utter junk then, instead of dignifying it by calling it a generalisation ;) 17:55:49 I did. I said it is wrong. It is a generalization. A wrong generalization. 17:56:28 'generalisation' means to me that it is a model that works in many cases 17:56:45 I recommend you learn the actual facts about these things. They aren't lengthy or complicated to start with; they don't need boiling down. 17:56:57 but anyway, we're pretty far off the more interesting subject -- postpone, what does it really mean? 17:57:29 What reference materials do you have available? 17:58:23 my longer attempt at explaining postpone would have gone something like this: postpone is an immediate parsing word that adds the xt for the parsed word to the most recent word definition 17:58:59 the internet, and a few forth installations on my box (pforth, gforth, kforth, pfe) -- no actual books 17:59:20 POSTPONE does not have to be immediate. It does not add the xt for the parsed word to the most recent word definition. Have a look at the Standard document in the topic link. 18:00:14 if it's not immediate, then how does it parse? 18:00:22 I should really look at the link, shouldn't I? 18:01:41 POSTPONE only has compilation semantics, but a Forth implementation can provide those through whatever means it wishes; immediacy is only one possibility. 18:03:03 "Skip leading space delimiters. Parse name delimited by a space. Find name. Append the compilation semantics of name to the current definition. An ambiguous condition exists if name is not found." 18:03:09 marble: try is http://www.albany.net/~hello/inching.htm 18:03:40 this* 18:03:49 was I really that far off? it sounds like what I just said. but perhaps I was being loose with my nomenclature... 18:03:59 I pointed out where you were off. 18:04:35 Notice nothing in the definition requires it to be immediate. No mention of an xt is made. 18:05:39 Is there really another way of parsing something in compile more without immediate ? 18:06:23 A Forth could have an entirely different mechanism for accessing compilation semantics for a word that has nothing to do with immediacy. 18:07:41 eg: the colon compiler looking for postpone words? 18:07:56 That would not be a Standard Forth. 18:08:24 In a Standard Forth system, there is no 'colon compiler'. That's specific to a very old implementation of Forth. 18:08:29 I'm trying to think of something concrete -- a little here here please :) 18:09:36 I'm *definitely* being loose with my nomenclature -- I could have just said colon 18:09:44 *help 18:10:13 erider: what am I looking at? 18:10:52 nice intro to forth 18:11:13 Look at gForth's POSTPONE Tutorial. 18:11:55 : parses forward only as regards the name of the definition. It does not start a parsing loop. 18:12:16 There are very old Forth systems in which : is a separate parsing loop. 18:13:23 http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/POSTPONE-Tutorial.html#POSTPONE%20Tutorial ? 18:13:46 Yeah. 18:17:51 ah! so if there are 2 fields in every word, one for the interpretation semantics, one for the compilation semantics 18:18:31 we can set postpone's compilation semantics to be: set some piece of state 18:19:09 It can be implemented in any manner that meets the requirements. Immediacy is only one option. 18:20:19 that brings the number of options I know about to 2 18:21:16 If you only knew about one, the field is still open for there to be another. Adding statements about immediacy and xts to your understanding of POSTPONE is not helpful, and not, in fact, valid. 18:22:00 : foo ( n -- n ) 1 swap 1+ 1 ?do i * loop ; can someone look at this and tell what is does? 18:22:07 erider, have you tried it? 18:22:24 yes 18:22:29 Won't it produce an error, assuming only one value is on the stack? 18:22:33 And what does it do? 18:23:01 it looks like its factoring 18:23:09 factoring? 18:23:32 like with I put 4 is == 24 18:23:44 Factorial, I think you mean. 18:23:48 Oh, uh, nevermind. 18:24:38 yes sorry 18:25:32 I can one get that out of that word? 18:25:42 What? 18:25:51 factorial 18:25:59 What about factorial? 18:26:32 if the is what it does how can one think of that with the words selected 18:26:53 I'm sorry, erider, I don't understand your question. 18:28:01 I'm looking at the code and I'm trying to figure out how someone could come up with that code to make a word to factorial 18:29:06 For one thing, that word works only for values 1 and greater; it returns a wrong answer for 0 and goes into a very, very long loop for negative values (and also then returns the wrong answer). 18:29:37 So it's broken, It does factorial for values of 1 and higher, and returns wrong answers otherwise. 18:30:03 really? 18:30:07 try it. 18:30:51 that really needs to be better documentation on line Quartus when is you book coming out? 18:31:06 s/that/there 18:31:18 No target date is fixed yet. 18:31:42 publisher? 18:31:46 Undetermined. 18:32:03 That 'foo' word just shows a sloppy implementation or understanding of the factorial function. 18:33:48 hmm 18:34:26 forth is a language of logic? 18:35:40 Forth is a general-purpose programming language. 18:36:21 I kept hearing that Quartus 18:36:52 It's true. 18:37:08 --- quit: Quartus_ (Read error: 104 (Connection reset by peer)) 18:37:16 but people say that one wouldn't see forth because placing like NASA use it 18:37:44 or embedded systems 18:37:58 Who and where and how visible has nothing to do with whether it's a general-purpose programming language. 18:38:26 true 18:39:10 but some can't seem to explain what they do with forth 18:49:28 * erider is liking this .NET forth is really neat... hmm and its kinda fast compiling 18:54:32 can you create a word that had the interpretation semantics of adding two numbers together, and the compilation semantics of subtracting instead? 19:01:31 --- quit: twobitsprite (Read error: 110 (Connection timed out)) 19:06:32 looks like there's nothing standard for it 19:09:09 hmm 19:17:19 Sure. : weird state @ if postpone - else + then ; immediate 19:17:43 --- quit: virl (Remote closed the connection) 19:22:06 Quartus: what does u. stand for? 19:22:26 Is there anything like ForthForge? 19:22:41 6.1.2320 in the Standard, erider. 19:22:42 yes 19:24:09 : a weird ; 19:24:18 : b postpone weird ; 19:25:26 1 2 weird . gives 3... 1 2 a . gives -1... 1 2 b . gives 3... 19:25:48 B is not a meaningful definition. You need to read what POSTPONE does, understand it better. 19:26:05 "Append the compilation semantics of name to the current definition." 19:26:25 Right. And you are using it... inside a definition? No. You're using it while interpreting. 19:26:49 The semantics are undefined. It may do something in one Forth, nothing in another. 19:27:10 : b postpone weird ; ... adds the compilation semantics of weird to b ? 19:27:14 No. 19:27:19 damn :P 19:28:08 This is what I mean. You can't approximate, cut down, mutter vaguely, squint and hope for the best -- you've got to read what is written and actually understand it, or you'll never make progress. 19:28:46 : b postpone weird ; ... b is the current definition ? 19:29:08 (for postpone) 19:29:43 I'm reading the words, but there's a subtly that's obviously escaping me 19:29:43 B is the current definition at the time POSTPONE WEIRD is encountered. You have picked one sentence out of the Standard definition for POSTPONE, out of its context, and are now using it like a blunt instrument. Read the whole definition. If there's a term you don't understand, search for it and read that. 19:30:31 http://www.taygeta.com/forth/dpans6.htm#6.1.2033 ? 19:31:05 B is current when POSTPONE WEIRD is encountered. POSTPONE WEIRD adds the *compilation semantics* of WEIRD to B. It does not add the *action* of WEIRD to B. It adds the *compilation semantics* of WEIRD. 19:31:37 B then effectively becomes a word *that can compile WEIRD into another definition*. The reason your particular version is of questionable use is that it's not IMMEDIATE. 19:32:38 : B POSTPONE WEIRD ; has no defined interpretation semantics, so its use while interpreting could explode, turn green, send a letter to Chuck Moore, or telephone the Pope. 19:32:40 the compilation semantics of weird are to subtract two numbers... 19:32:52 No. The compilation semantics of WEIRD is to POSTPONE - 19:33:25 postpone weird -- adds the compilation semantics of weird onto the *compilation* semantics of b? 19:33:38 (as opposed to the execution semantics?) 19:33:58 No. Your B is just a normal colon word. It's not immediate. It has no special compilation semantics; use of B inside another word will simply compile a call to B. 19:35:15 It isn't complicated; you've just started with your own sound-bite definition of POSTPONE, which is wrong, and you're basing subsequent conclusions on that, so they're also wrong. Back up! 19:36:54 * marble ponders "The compilation semantics of WEIRD is to POSTPONE -" 19:38:18 I interpreted your question. If you actually want a WEIRD wherein the compilation-semantics are to subtract two numbers, it's : WEIRD state @ if - else + then ; immediate which is indeed weird, and quite probably useless. 19:39:11 you'd have to have put a couple of numbers on the stack to avoid killing yourself, I guess 19:39:46 The point of which I can't imagine. The whole exercise is not practical in any way that I can see. But if you want a WEIRD that works as + while interpreting, but works at - while compiling, then the earlier one does that. 19:42:50 oh -- "[22:23] : b postpone weird ; ... adds the compilation semantics of weird to b ?" in fact is yes. But you need to understand what the compilation semantics of weird actually are. 19:43:43 :P 19:44:12 And they are POSTPONE - not - 19:46:22 : weird state @ if - else + then ; immediate ... in this version, the compilation semantics is - 19:46:36 Right. 19:47:05 : b postpone weird ; ... adds the compilation semantics of weird to be... ie adds - to b ? 19:47:25 Not with the version you just posted, no. 19:47:39 Sorry. No to the question above, too. Sorry, I'm on the phone at the same time. 19:47:49 no worries :) 19:48:22 I think I need a worksheet 19:48:32 The compilation semantics of the weird definition you just showed is to immediately subtract two numbers. 19:49:13 : b postpone weird ; immediate will do the same thing as weird, while compiling. 19:50:25 I notice that you've added an immediate to b... is that important ? 19:50:29 Yes. 19:51:18 could we use b in the interpreter without immediate ? 19:52:20 Not with defined behaviour, not with or without immediate. B contains only compilation semantics. As I said before -- it could explode, halt and catch fire, sing the anthem, or recite a manifesto. 19:53:15 lol 19:57:13 What it will *probably* do in most implementations is to execute WEIRD, which would then execute +. But there's no guarantee of that. 19:58:38 let's restart with something a little less exotic ;) 19:58:45 : add + ; 19:59:00 interpretation semantics: adds two numbers 19:59:34 compilation semantics: appends the interpretation semantics of add to the current definition 20:01:04 : a add ; ... appends the interpretation semantics of add to a ... a adds two numbers 20:01:56 : b postpone add ; ... appends the compilation semantics of add to b ... b appends the interpretation semantics of add to the current definition 20:02:31 Wrong terminology. : add + ; has execution semantics. Its interpretation semantics are its execution semantics. Its compilation semantics are default, which is to append its execution semantics to the execution semantics of the current definition. 20:02:46 This is all mapped out in the standard. 20:04:00 ok 20:04:46 : a add ; ... appends the execution semantics of add to a ... the execution semantics of a is to add two numbers 20:05:07 effectively, yes. 20:06:04 : b postpone add ; ... appends the compilation semantics of add to b ... the execution semantics of b is to append the execution semantics of add to the current definition 20:07:06 we can use immediate to get b to execute during compile time 20:07:16 Right. 20:07:52 at interpretation time there is no 'current definition' so executing b is a no-no 20:10:27 : weird ( interpretation semantics: adds two numbers; compilation semantics: subtracts two numbers ) CODE-GOES-HERE ; MAYBE-SOME-STUFF-HERE-TOO 20:10:58 : a weird ; \ execution semantics: adds two numbers 20:11:42 what is 'maybe-some-stuff-here-too'? 20:12:05 I just put that there to be on the safe side :) 20:13:13 let me have another shot at a 20:14:07 : a weird ; \ this dies 20:15:17 dies? 20:15:21 : b postpone weird ; ... appends the compilation semantics of weird to b ... the execution semantics of b is to subtract two numbers 20:15:53 no postpone, so the compilation semantics of weird are executed during the definition of a ? 20:16:09 Ok, but no death is involved. 20:17:16 wouldn't it eat any data that might have been put on the stack for compilation purposes? 20:17:43 Depends on how you define it. You didn't show code, you described it in general terms. I don't know if you mean that it compiles - or does - right then. 20:18:02 does - 20:18:26 I don't know how to write weird, that's why it's just a description 20:18:29 I suspect you'd be happier working with code that has some actual meaningful purpose, rather than a word that adds while interpreting and subtracts while compiling, which is both confusing and completely freaking useless. 20:19:40 I'm just trying to understand things at this stage 20:20:06 WEIRD, as I defined it earlier, is what's called 'STATE-smart' -- it checks the value of state and does different things depending. This is a really craptastic way to write code. Far better in the vast majority of cases is to write two words, one that does what you require during compilation, one that does what you require during interpretation. 20:21:38 It is sometimes then a convenience to group both into a third, STATE-smart word, but even if that's done, factoring the functionality is cleaner, and code written using the factors is easily understood in terms of its action. 20:25:03 using the state variable is just one particular implementation technique -- we could have a forth had a field for interpretation-and-execution semantics and a field for compilation semantics -- and provided a way to populate them both? 20:25:22 That would be specific to that Forth. 20:25:27 yes 20:26:20 POSTPONE is a Standard Forth word. The only portable way in a Standard Forth to write words with special compilation semantics is to use IMMEDIATE. 20:27:52 The mechanism is more than sufficient for any purpose I can think of. You need to understand what POSTPONE actually does, but it really doesn't come into play very often. 20:28:09 The vast majority of Forth programming doesn't use it, nor does it require immediacy. 20:28:41 are my comments for a and b right? a fails to compile, and b subtracts two numbers ? 20:29:45 'a' may or may not fail to compile, that depends on the particular Forth, as you're invoking undefined behaviour again. 'b' is not immediate, and so will not do anything special during compilation; during interpretation it, again, invokes undefined behaviour. 20:30:15 ok on 'a' 20:34:18 when I defined b using add (not weird), I said: 20:34:22 : b postpone add ; ... appends the compilation semantics of add to b ... the execution semantics of b is to append the execution semantics of add to the current definition 20:34:22 we can use immediate to get b to execute during compile time 20:35:02 You did. 20:37:15 I'm only marking b as immediate to get it to execute at compile time 20:37:22 Ok. 20:37:36 I would have expected it to execute at interpretation time even without the immediate 20:38:06 It may, on some Forths. It is not required to. It's undefined. 20:39:03 Try it in Gforth. : add + ; : b postpone add ; 3 5 b . 20:39:54 You see it does not work. 20:40:02 It does not add 3 and 5 to produce 8. 20:40:07 I haven't tried it yet -- I'm looking at the logs :) 20:40:56 Me: "the execution semantics of b is to append the execution semantics of add to the current definition" 20:41:31 at interpretation time there is no current definition, and so the world explodes 20:41:35 So if you use it while interpreting, there's no current definition, and the behaviour is undefined. 20:42:34 whereas b defined using weird: 20:42:42 : b postpone weird ; ... appends the compilation semantics of weird to b ... the execution semantics of b is to subtract two numbers 20:43:20 b doesn't need a current definition, all (I think) it does is subtract two numbers 20:43:24 No. Compilation semantics are not required to be executable when not compiling. The behaviour is undefined. 20:43:35 It will *probably* subtract two numbers when interpreting. You cannot rely on this. 20:44:54 If I'm defining the compilation semantics for something, and I know it 'works' at interpretation time 20:45:27 If a word is STATE-smart, you know which branch of its conditional it will take at interpretation time. 20:45:38 if that word is postponed in a definition, and that definition run without having been marked immediate -- is it still undefinied? 20:45:58 state-smart is only one implementation techique 20:46:02 Immediacy is irrelevant during interpretation. It does not change whether the behaviour is undefined. 20:46:47 marble, you cannot go back and forth between a specific example and some imaginary unspecified one. B will *probably* just do the interpretation branch of WEIRD if called while interpreting. It doesn't have to, and if you want portability, you need to know that. 20:46:54 *is* it undefined if I originally defined it to work? 20:47:22 Yes, it is undefined by the Standard. A given Forth may have defined behaviour for that case. 20:47:49 hmmm 20:49:00 a forth can be compliant with the standard, and yet its code not be portable 20:49:06 Consider that the appending of compilation semantics to the current definition requires a current definition. A given Standard Forth implementation could, completely compliantly, check that a definition is currently being built before attempting to append any compilation semantics. Attempting to do so in interpretation state would then simply fail. 20:49:46 hmmm 20:50:08 A Forth can be a Standard Forth or not; a program can be a Standard Program or not. Both are defined in the Standard. Certainly you can write a program that isn't a Standard Program with a Standard Forth. 20:50:45 adding compilation semantics to an execution semantics is like a taint? 20:51:16 Relying on undefined behaviour will produce different results on different systems. 20:51:55 What other languages do you know? 20:51:58 C? 20:52:19 basic, c++, delphi, ml, java, haskell, prolog, c 20:52:24 probably others 20:52:46 Remind me, is integer division by zero defined behavior in C? 20:52:47 (well, my java knowledge is probably a joke at this state) 20:53:16 it's probably machine defined 20:53:44 But not defined by the language standard, as far as I recall. So suppose integer division by zero always returned 0 for a given standard C implementation, and you rely on that. 20:54:08 this analogy is a little far :) 20:54:18 It isn't. I'm talking about undefined behavior. 20:54:24 I'm not read all of the forth standard 20:54:34 If it's undefined, it may do what you want. It may not. It's undefined. 20:54:37 I've only looked up the description of some of the words 20:54:57 in the description I have read, there's nothing I can find about needing to use IMMEDIATE with POSTPONE 20:55:06 I'm not referring to how much of the standard you've read. I'm trying to illustrate the nature of undefined behavior in a language standard, and how it might apply in a language you already know. 20:55:22 if you say that that's all mentioned in some other part of the standard, then I'll happily take your word for it 20:55:47 You don't need to use immediate on a word containing postpone. It's just probably useless if you don't. You could, though, do this: : a postpone + ; : b a ; immediate : c 3 5 b . ; 20:56:41 I know what 'undefined' means -- I've coded C++ ! ;) 20:57:13 Here's another practical example: : constant >r : r> postpone literal postpone ; ; 20:57:16 Note no immediate is used. 20:57:47 That's a version of CONSTANT that works just as the Standard CONSTANT does. 20:57:58 So 42 constant x x . -> 42 20:58:22 Quartus: can I define a variable inside : 21:00:11 You mean : foo [ variable x ] ; ? No. 3.4.5 "A program shall not attempt to nest compilation of definitions." 21:03:16 ok thanks 21:06:13 that's really too complicated for me to follow 21:06:26 You should figure it out; it's instructive. 21:06:56 The definition is only seven words long. 21:07:22 Using that constant, 42 constant x is exactly equivalent to : x 42 ; 21:09:26 >r appends the execution semantics of >r to constant 21:09:29 A more typical CONSTANT is : constant create , does> @ ; but the one I show above is completely legitimate, and in fact is the one Quartus Forth uses, with one addition -- a special flag that gives it special compilation semantics for optimization. 21:10:06 : r> sets the current definition to r> 21:10:11 No. 21:10:26 : is not immediate. 21:11:56 ok 21:12:22 That is, : has no non-default compilation semantics. 21:12:22 : appends the execution semantics of : to constant 21:12:30 It does. 21:13:03 r> appends the execution semantics to r> to constant 21:13:45 Sure. So so far : constant >r : r> ... will perform >r : r> ... which should come as no surprise. :) 21:14:19 postpone literal appends the compilation semantics of literal to constant 21:14:42 Yes. 21:17:35 the compile time semantics of literal is to take a value off the stack, x, and append (push x) to the current definition 21:18:03 Vaguely put, but yes. 21:19:00 postpone ; appends the compilation semantics of ; to constant 21:21:00 the compile time semantics of ; is to append sometime to the current definition to allow it to return to its caller, and then to end the current definition 21:21:34 Right. 21:21:51 So using that constant, 42 constant x has exactly the same effect as if you'd typed : x 42 ; 21:27:23 the execution semantics of constant is to: move the value on the data stack to the return stack, begin a colon definition which takes the next word after constant, moves the value on the return stack back to the data stack, takes the value off the stack, x, and appends (push x) to the current definition, appends something to the current definition to allow it to return to its caller, the current definition is then ended, and consta 21:27:23 nt returns 21:28:06 Yup. So 23 constant moo will result in exactly : moo 23 ; 21:28:17 the execution semantics of the thing defined by constant: -- x 21:28:28 Right. moo . -> 23 21:28:39 and there is no immediate ? 21:28:46 As you see. 21:28:54 and this is well defined? 21:29:00 It's a thing of joy and beauty. 21:30:09 why does this not need immediate, as opposed to b/weird which does? 21:30:33 because the postpones are operating inside a 'current definition' ? 21:30:39 For a simple reason: it enters compilation state itself (with :). It's not already in compilation state when called, so there's no need for it to be immediate. 21:32:56 * erider is wondering what this postpone thingy is all about 21:33:14 erider, that's all we've been talking about. You should review the log. 21:33:17 for executing 'compilation semantics', does one need anything other than a 'current definition' ? 21:33:27 marble, that's all. 21:33:57 * erider is trying to learn String Operations 21:34:04 is this mentioned somewhere in the standard ? 21:34:12 marble, what exactly are you looking for? 21:34:24 --- join: arke_ (n=Chris@pD9E077DB.dip.t-dialin.net) joined #forth 21:34:53 "compilation semantics: The behavior of a Forth definition when its name is encountered by 21:34:53 the text interpreter in compilation state. 21:34:53 " 21:35:16 You can then find what words put you into compilation state. 21:38:31 oh 21:39:01 Which I think are inclusive of ] : and :NONAME, with only : and :NONAME producing a current definition. 21:40:04 we could have saved some hours had I seen that definition earlier ;) 21:40:25 Doubtless actually reading the Standard will save you a great deal of pointless wandering. :) 21:41:17 There are default compilation semantics, and special ones; those are detailed per word as appropriate. 21:42:06 So anyway, I hope you can see we're several hundred miles away from "postpone ignores the immediate bit." :) 21:44:12 a couple of feet by my reckoning: "postpone ignores the immediate bit, and the resulting code is only define in the compilation state" ;) 21:44:21 *defined 21:44:58 POSTPONE most assuredly does not ignore the immediate bit. 21:45:17 query is going to look for all 80 chars? or can that be controlled 21:45:33 query, as a Standard word, is deprecated. 21:46:58 How many characters it reads is up to the implementation. 21:47:28 ACCEPT is your friend. 21:49:55 accept? so accept instead of query? 21:50:07 Yes, ACCEPT instead of query, ACCEPT instead of expect. 21:50:38 accept puts its input in tib? 21:50:41 QUERY effectively does ACCEPT and then EVALUATE. 21:50:54 ACCEPT puts the input wherever you specify. 21:51:11 --- quit: arke (Read error: 110 (Connection timed out)) 21:53:37 * erider is looking for an example of accept 21:54:25 create input 40 chars allot input dup 40 accept cr type cr 21:56:53 thats cool! 21:58:05 Put evaluate instead of type, and it'll be doing something like query. 21:58:18 create input 40 chars allot input dup 40 accept evaluate for instance 21:58:53 how is the evaluate acting it that example? 21:59:13 how? it's evaluating the same string that would have been typed in the cr type cr example above. 22:00:03 evaluating it for what? 22:00:10 EVALUATE. Check the Standard please. 22:00:41 roger :) 22:01:56 Quartus, erider: I'm off. No doubt I'll be back again soon to drive you all mad :> 22:02:06 --- quit: marble (".") 22:05:23 --- quit: nighty (Remote closed the connection) 22:20:54 --- nick: arke_ -> arke 23:59:59 --- log: ended forth/06.11.23