00:00:00 --- log: started forth/09.05.11 00:45:15 --- quit: malyn ("Disconnecting from stoned server.") 00:45:29 --- join: malyn (n=malyn@unaffiliated/malyn) joined #forth 00:49:49 --- join: pippin_ (n=pippin@bilk.XCF.Berkeley.EDU) joined #forth 01:01:50 --- quit: pippin (Read error: 110 (Connection timed out)) 01:27:05 --- quit: proteusguy (Read error: 104 (Connection reset by peer)) 01:27:15 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 02:16:41 --- join: X-Scale2 (n=email@89.180.162.124) joined #forth 02:22:21 --- quit: X-Scale (Read error: 60 (Operation timed out)) 02:41:26 --- nick: X-Scale2 -> X-Scale 03:43:57 --- join: gogonkt_ (n=info@58.248.188.163) joined #forth 03:57:06 --- quit: gogonkt (Read error: 110 (Connection timed out)) 04:43:43 --- quit: nighty^ ("Disappears in a puff of smoke") 05:45:51 --- join: benny99 (n=benny@p5486B81D.dip.t-dialin.net) joined #forth 07:38:18 --- quit: proteusguy (Remote closed the connection) 07:41:42 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 08:04:23 --- quit: proteusguy ("Leaving") 08:20:01 --- join: GeDaMo (n=gedamo@212.225.108.65) joined #forth 08:23:00 --- join: Vanax (n=Spock@cpe-77-83-251-90-dsl.netone.gr) joined #forth 08:43:59 --- quit: Vanax ("Ex-Chat") 09:29:38 --- join: hagna_ (n=hagna@70.102.57.178) joined #forth 09:59:07 YOU FORTH LIKE IF HONK! 10:13:39 THEN? 10:15:17 branch -6 10:18:05 are there any good tutorials for defining new ":" words like "imm:" ? 10:20:57 "imm:" for example is supposed to replace ": bla ... ; immediate" with "imm: bla ... ;" 10:26:47 : imm: : postpone immediate ; \ does not work 10:27:49 immediate affects the last compiled word 10:28:54 GeDaMo, yeah -- so I thought 'compile word using : normally and add an immediate' would work 10:29:18 Except the compilation of the word hasn't finished at that point 10:29:58 ? 10:30:19 : begins compiling a word 10:30:31 Then you execute immediate 10:30:40 The compilation doesn't finish until ; 10:31:16 imm: s" Hey GeDaMo" type ; \ finds a ';' 10:31:41 ah 10:31:55 But the postponed immediate executed before it got to that point 10:32:25 so ':' does not read from the input after 'imm:' but reads immediately ? 10:32:50 No, it reads when you execute imm: 10:33:12 so it should be alright ? 10:33:29 The : is not the problem 10:33:32 : s" Hey" type ; immediate \ works 10:33:46 : bla s" Hey" type ; immediate \ works 10:33:56 Yes, because the immediate comes after the compilation has finished 10:34:06 :/ 10:34:27 : begins compilation ; finishes it 10:34:45 "in my world" imm: is executed; there ':' is executed reading what is coming after 'imm:' till ';' 10:35:08 You've redefined : ? 10:35:11 no 10:35:23 : reads only one token out of the input stream 10:35:24 : imm: : immediate ; immediate \ probably wrong 10:35:33 ah 10:35:37 The name of the word to define 10:36:43 I see, ok 10:37:46 hm 10:38:34 Forth reads one token at a time, looks it up in the dictionary then executes it (interpret mode) or compiles it (compilation mode) unless it's immediate in which case it executes it 10:39:14 yep, thanks - though I know that much about forth - I just try to use it 10:39:20 what is ultra-hard immo 10:40:46 The point I was making is that it continues to read one token at a time regardless of the mode 10:41:54 Of course parsing words can read arbitrary amounts of text out of the input stream 10:42:02 I understood, but I still wonder how I could define that word that I'm looking for 10:42:10 though it looks extremely easy, it's probably not hm ? 10:43:16 Is there some particular reason you want to do it? 10:44:15 GeDaMo, I want to add some extra information to words 10:44:35 GeDaMo, and I want to understand forth :p 10:46:14 : imm: : [char] ; parse evaluate postpone ; immediate ; 10:46:21 A bit of a hack :P 10:50:02 imm: s" Hello" type ; -- *evaluated string*:-1: Undefined word 10:50:39 You didn't supply a name for the word to be defined 10:51:07 Or rather it redefined s" 10:51:08 -.- ... of course, sorry, thank you 10:52:42 It'll fail if there's an ; other than the one which ends the definition 10:54:04 could there be another ? 10:54:38 There might be one in a string 10:54:46 Or as part of another word name 10:55:46 hmk 10:55:53 imm: semicol char ; ; does not work 10:57:14 That wouldn't work anyway, you'd need to use [char] ; inside a definition 10:58:05 imm: semicol char ; \ works 10:58:11 sorrs -- [char] 10:59:34 I think you'll find it hasn't worked as you intended 10:59:48 yeah 10:59:56 is it impossible to do that ? 11:00:17 To do what? 11:00:35 who knows - probably not, but connected to a lot of effort hm ? whatever -- making 'imm:' 'really work' 11:01:16 I can't think of an obvious way 11:03:56 s" Squares." docword: square * dup ; -- docword: is supposed to execute if executed (:-[), and it's possible to show it's documentation by e.g. " ' square showdoc" 11:04:00 not easier hm ? 11:04:54 I think you have * and dup around the wrong way 11:05:05 ( hm, there's noname: ) 11:05:08 I do 11:07:02 Have you defined docword: ? 11:07:40 no 11:07:47 I try to at the moment 11:08:56 I seem to remember a redefinition of : which did profiling 11:09:55 It stored the profiler information with the word 11:10:05 ( "all I need to do is" create a word, compile like : does and add the string after the code ) 11:11:14 ( or save a pointer to the code at the beginning, save the string, compile in the code and do "@ execute" on does ) 11:12:18 btw.: I'm just playing around, so don't bother too much - I just want to understand forth a bit more 11:14:47 That's ok, I like playing around :P 11:15:44 great :) 11:19:53 :noname looks interesting for this job ... maybe 11:20:36 --- join: kar8nga (n=kar8nga@f-61.vc-graz.ac.at) joined #forth 11:20:41 Possibly 11:21:16 ":NONAME can be used to create application-specific programming languages. " 11:21:20 http://www.taygeta.com/forth/dpansa6.htm#A.6.2.0455 11:22:57 "As a further example, a defining word can be created to allow performance monitoring. In the example below, the number of times a word is executed is counted. : must first be renamed to allow the definition of the new ;." 11:23:05 GeDaMo, that's your profiler I guess ? :p 11:23:13 Could be 11:23:49 Yeah, that's it 11:24:08 Instead of the profiling information, you could store the info for your doc string 11:27:39 : doc create :noname , , , does> @ execute ; \ does not work 11:28:25 That's because does> is trying to replace the action of the definition created by :noname 11:29:13 * benny99 is unable to read docs ? ... again ? 11:29:53 Well you're trying to do something compilcated :P 11:29:54 :noname ( S: -- xt ) \ ? 11:34:27 I thought :noname was giving me an xt of some compiled code 11:34:39 It should be 11:35:04 it does 11:36:43 hm, ": doc: create :noname ( compile code, get xt ) , ( place xt in the defined word ) , , ( place string ) does> @ ( get xt of compiled code ) execute ; 11:36:49 what am I missing this time :/ 11:37:26 (19:28:25) GeDaMo: That's because does> is trying to replace the action of the definition created by :noname 11:37:37 "does> replaces the action of the definition by :noname" .. as you say 11:37:37 Take a look at the profiler example 11:37:38 yeah 11:38:01 I don't understand it 11:39:04 See where it redefines : ? 11:39:11 it places the code before the string 11:39:29 It creates a new word and stores some data 11:39:44 yeah 11:39:52 Then call :noname to compile the word 11:40:12 ; is redefined to store the xt with the newly created word 11:40:23 so :noname compiles the code to "here" ? 11:40:33 Yes 11:40:40 ah ... 11:40:44 Well, more or less 11:40:57 You can't guarantee exactly where it is 11:41:06 :D 11:41:06 It depends on the implementation 11:41:12 ah 11:46:49 --- join: tathi (n=josh@dsl-216-227-91-166.fairpoint.net) joined #forth 11:47:18 impossible :/ 11:47:41 hi all 11:48:32 Hi tathi :) 11:48:40 hi 11:50:02 what's impossible? 11:50:05 :) 11:50:27 http://forth.pastebin.ca/1419533 <- 11:51:03 argh 11:51:43 you want to attach a documentation string to a word? 11:52:04 oh, btw, [compile] and postpone are not exactly the same -- [compile] is a no-op when used on a normal word 11:52:21 (from last night) 11:52:58 tathi, yeah, my memory failed me :P 11:53:01 tathi, exactly, desperately :p 11:53:10 ah 11:53:20 benny99: I have the doc thing working 11:53:29 normal word --> not compile-only word ? 11:53:40 GeDaMo, I don't :/ 11:53:51 yeah, one with "default compilation semantics" 11:54:02 http://forth.pastebin.ca/1419535 11:54:13 tathi, ok :) 11:54:27 How are you going to use the doc string thing? 11:54:38 argh, still none-sense 11:54:53 no, I'm probably not going to use anything 11:55:04 ah. 11:55:24 Hmm... you should just be able to do : imm: : immediate ; 11:55:54 tathi, nope 11:56:08 give me an example where it doesn't work for you? 11:56:41 it works fine for me 11:59:30 http://forth.pastebin.ca/1419543 11:59:55 tathi, I forget to give the word a name ... again ... 12:00:02 tathi, sorry, thank you :) 12:01:35 GeDaMo: well, you can't rely on interpreted strings being permanently stored. 12:01:44 is >body ans-forth ? 12:01:48 although it looks like on gforth they are 12:01:49 benny99: yes 12:01:58 ok 12:02:33 tathi: good point 12:02:37 I think that personally I'd just make a "help" vocabulary or something and compile the string there witht the same name. 12:03:19 But if it's just an exercise... :) 12:04:10 Just playing around :) 12:04:24 well, I can't even do exercises at the moment, so what would you expect :p 12:07:31 :noname is placed after does> .. ah 12:07:58 yeah, otherwise the does> will try to change the behavior of the :noname definiion 12:10:55 it still does not work :D 12:11:03 ( my version ) 12:12:06 Do you still have the does> and :noname in the same word? 12:12:08 did you factor out the does> part to a separate word? 12:12:14 :) 12:12:21 it works =D 12:12:29 no, I didn't 12:13:05 though I don't got a clue yet why I had to factor that out 12:13:18 everything from does> on is the behavior for the CREATEd word 12:13:51 so you can't just put the :noname after does>, because then it won't get executed when you use doc: 12:14:26 does that make sense? 12:14:41 no 12:15:01 postpone @ postpone execute does not work either .. that's probably silly anyway 12:15:27 ok, do you understand what create and does> do? 12:15:51 hard to say what understand means -- I guess I don't 12:16:52 create makes words that can contain arbitrary data, and by default those words just return the address of the data, right? 12:17:19 yep 12:17:27 does> allows you to add code to a created word to do something with the data. 12:17:40 but it's black magic ? 12:17:44 basically everything after does> is a new definition 12:17:58 that gets tacked onto the end of each CREATEd word that uses it. 12:18:10 tacked ? -- ticked ? 12:18:17 Attached 12:18:18 appended 12:18:40 yeah 12:18:40 ok 12:19:34 so if you do for instance : defer ( "name" -- ) create ['] noop , does> @ execute ; defer foo 12:19:53 then when you run foo, it puts its address on the stack, and jumps to the does> code (@ execute). 12:19:56 it executes noop 12:20:05 yep 12:20:05 yeah 12:20:24 if you define more words with defer, they each have their own data, but they share the same behavior 12:20:37 the implementation is usually kind of hairy, but you don't have to care about that. :) 12:20:49 they share the same behaviour -- they share the same code ? 12:21:15 yeah, on all implementations that I've looked at. 12:21:22 the @ execute part, anyway. 12:21:40 ok 12:22:15 so the reason for factoring out docolon is? 12:22:25 think it through... 12:22:28 ah 12:22:29 wait 12:22:35 :-[ ok 12:22:36 : doc: create ... does> @ execute :noname ; 12:22:50 s" blah blah blah" doc: foo ... ; 12:22:51 it executes :noname 'too late' 12:22:58 yup. when you run foo. 12:23:07 because it does that when doc: is invoked of course 12:23:11 yep ok 12:23:27 and since you (usually) can't nest definitions inline, you have to pull it out to its own definition. 12:24:05 ok, that was a silly thing for me to say, I guess. :) 12:24:34 and postponing is still not nesting definitions inline ? 12:25:09 postponing just adds the compiling behavior to the definition instead of the interpreting behavior 12:25:41 : doc: create .. does> postpone @ postpone execute ; would define words that *compile* @ execute 12:26:03 postpone does> postpone @ postpone execute ? 12:26:39 still no... then it would compile 'does> @ execute' when you run doc: 12:27:27 but it wouldn't get compiled anywhere useful. 12:27:37 I still don't get it I think :( 12:27:43 * benny99 feels dumb 12:27:43 sorry 12:27:55 no, it takes everyone a while 12:28:08 there's interpretation, compilation and run-time 12:29:08 try thinking through what would happen if you did create ... postpone does> postpone @ postpone execute 12:29:17 it's hard to think about "compiling something that is meant for interpreting, that is then when run, doing what's doing when it's interpreting" or something like that 12:30:15 yeah. just take it one step at a time. 12:30:20 if I compile for example C, it's absolutely clear what's compiled, i.e. what I see (except for the preprocessor :/ ) 12:30:35 right, because C doesn't have real macros. :) 12:30:37 *-thingies 12:31:02 ok, so create makes a data word 12:31:06 in lisp you have 12:31:09 then you put data in it 12:31:16 yeah, that's clear 12:31:23 ok 12:31:27 then you postpone does> -- note that this code is in limbo 12:31:37 if I type something, is that run-time or 'interpretation-time' ? 12:31:40 you're not in a colon definition 12:31:50 at the shell 12:31:51 so compiling something doesn't really make sense 12:32:21 interpret time 12:32:32 ok 12:32:35 there isn't really a "run-time" that you have to think about...I don't think. 12:33:09 it's pretty interchangeable with interpretation-time 12:33:10 ( except for looking at the program running as a whole maybe ? ) 12:33:22 yeah, maybe. 12:33:56 ( variable x ... bla bla ... set x 10 ... x 10 = if <-- it's clear what happens at run-time, but not at 'interpret-time' ) 12:33:57 the Standard uses "run-time" to refer to definition fragments, like when specifying postpone and does> 12:34:07 hmm 12:34:10 run-time as distinct from compile-time for immediate words 12:34:11 ok 12:34:24 hmk 12:34:58 well, you can't generally use 'if' outside of a definition 12:35:06 but docolon is 'invoked' isn't it ? 12:35:17 yeah 12:35:27 as part of doc: 12:36:13 so does> @ execute is executed in a different environment ? 12:36:22 when I create the word ? 12:36:26 :/ does not make sense 12:36:49 no, it's executed in the same environment, if I understand you 12:37:02 the reason you have to factor it out is just a quirk of the syntax 12:37:24 you want to put something after the does> section 12:37:34 "does> @ execute" is not the same as if I was running "docolon" that executes "does> @ execute" ... I don't get it :/ 12:37:44 but the only way to end the does> section is with a semicolon, which also ends the whole definition. 12:37:54 ah. 12:38:27 now I got it :) 12:39:10 * benny99 understands 12:39:28 once I finally got rid of the jargon and found simple words to explain it? :) 12:39:59 tathi, no :-[ ... "the only way to end the does> section is with a semicolon, which also ends the whole definition" 12:40:33 yeah, instead of trying to explain the semantics of each individual word. 12:40:54 I thought of any word as 'a kind of shortcut' for it's content before 12:40:59 its 12:41:20 tathi, then yes :) 12:41:21 yeah. but most of the syntax stuff breaks that a little bit 12:41:59 yeah, but no <-- hmk :p 12:42:37 * benny99 again learned a lot 12:42:55 maybe I should explain the interpret/compile loop briefly too...? 12:45:07 what is read from stdin is interpreted -- if I start a colon-defintion and end it with ; it's compiled (for example) , no? -- yeah, would be great :) 12:46:09 you can think of it as being one "interpreter". It takes one line at a time, and simply parses a whitespace-delimited word and handles it. 12:46:28 In interpretation state, the words are executed, in compilation state they are compiled. 12:46:43 tathi, I know that whether a word is imm or not is saved in the word and that there's a state-switch (somebody said should not be used) 12:47:01 that's clear 12:48:21 yeah. making words with "state @ if ... else ... then" can give unexpected behavior if you use postpone or ' on that word and it gets executed in the wrong state. 12:48:40 but that's a quality-of-implementation thing. 12:48:57 ok 12:49:10 Elizabeth Rather says she likes to teach that words have *two* behaviors (one for interpretation, one for compilation)> 12:50:07 of course, normally the compilation behavior is to compile the interpretation behavior 12:50:30 but not if it's imm 12:50:38 right 12:50:52 and [ ... ] "makes" ... imm 12:51:06 er...not exactly. 12:51:09 ok 12:51:12 it just switches back to interpretation state 12:51:45 ok, of course 12:52:00 ] means switch to compilation state, [ switches to interpretation state 12:52:36 it's all the same text processing loop, it's just the word handler that changes. 12:52:46 ] bla [ is still not equal to postpone bla ? 12:53:01 No 12:53:29 note that ] is not immediate 12:53:55 so if you did that in a definition, it would compile ] into your word :) 12:54:24 aah 12:54:29 ( explains a lot ) 12:54:37 if you did it outside of a definition, bla would just get compiled onto the heap, and then never executed. 12:54:48 ok 12:55:34 try for instance here ] dup [ here over - dump ' dup hex. 12:56:30 er. I'm not sure that's helpful, but... 12:57:18 you can see that it compiles something into memory, anyway. And in gforth it happens to be the xt 12:58:19 ( helpful ) 12:58:27 yep 12:59:22 I guess another thing to realize is that Forth isn't like C or most other languages -- there is no grammar. The control-flow words may *look* structured, but really they're just separate words designed to work together. 12:59:54 :D I noticed that so far -- and I also read ( parts ... ) of books 13:00:04 IF compiles a forward conditional branch, and puts something on the stack so that THEN or ELSE can resolve the branch to point to the right place. 13:00:07 that sort of thing. 13:00:14 yep 13:01:07 so you really just have to take it one word at a time and track the state in your mind. 13:01:23 Which of course can get tricky with does> and postpone and so on. :) 13:01:26 --- join: GoNoGo (n=GoNoGo@cro34-3-82-236-93-215.fbx.proxad.net) joined #forth 13:01:34 especially with does> :p 13:02:11 The difficulty is it's always obvious which words are immediate 13:02:25 not always ? 13:02:27 Yeah. The thing about does> is that it really marks the end of the current definition and the start of a new (partial) definition. 13:03:18 Er, yes. not always :P 13:03:30 ( retroforth made that kind of two definitions as far as I remember ) 13:03:49 ( yeah, I know, that is far off ans-forth - not forth at all ) 13:04:10 yeah, retroforth/helforth/4p use a somewhat different system. 13:04:24 trying to remember exactly how that worked...it has been a while... 13:04:27 well, I know about does> now :p 13:04:32 hehe. 13:04:43 that's a big hurdle. 13:04:44 doesn't matter immo I guess ;) 13:05:05 yeah, I just have this morbid fascination with quirky forth implementations. :) 13:06:02 http://www.annexia.org/_file/jonesforth.s.txt <- you probably know that then ? 13:06:20 yeah 13:07:47 The problem I have with that sort of thing is that it pays lots of attention to all these implementation details that are mostly irrelevant IMO. 13:07:59 learned some of the forth internals there, though it didn't tell me of course 'beware of does>' 13:08:10 yeah 13:09:51 One day I'd love to write a small Forth (maybe even *in* Forth) which emphasizes the things that Forth systems have in common, and leaves the implementation details to an appendix. :) 13:09:51 --- quit: kar8nga (Read error: 54 (Connection reset by peer)) 13:10:13 Actually I'd like to include several different "back-ends" so people could see some of the different possibilities. 13:10:16 http://www.bradrodriguez.com/papers/ <-- ( since I'm pasting URLs already ) 13:10:30 Yeah, he has some good stuff. 13:10:47 Have you seen Stephen Pelc's book? I've been recommending that lately. 13:10:56 ( well, isn't that ans-forth :p ?) 13:11:13 yeah, read big parts of it 13:11:51 I found it great btw. (but I read it kind of quickly, don't blame him :p ) 13:12:18 great, or not so great? 13:12:33 great -- good 13:20:56 * benny99 learned enough for today 13:21:29 thanks for your patience :) 13:23:13 have fun 13:24:05 ( things I'll try tomorrow: define a defining defining word ) 13:24:10 bye :) 13:26:33 --- quit: benny99 ("Leaving") 13:46:41 --- quit: GoNoGo ("ChatZilla 0.9.84 [Firefox 3.0.10/2009042316]") 14:41:30 --- quit: GeDaMo ("Leaving.") 16:08:01 --- quit: maht (Read error: 104 (Connection reset by peer)) 16:09:02 --- join: maht (n=maht__@85.189.31.174.proweb.managedbroadband.co.uk) joined #forth 16:32:32 --- join: forther (i=cf2f2264@gateway/web/ajax/mibbit.com/x-6542a702b7054b34) joined #forth 16:32:42 hi 16:35:13 --- join: tgunr (n=davec@polymicro.net) joined #forth 16:41:57 hi 16:51:10 --- quit: forther ("http://www.mibbit.com ajax IRC Client") 17:05:06 --- join: nighty^ (n=nighty@210.188.173.245) joined #forth 19:35:33 --- join: madgarden_ (n=madgarde@CPE001d7e527f89-CM00159a65a870.cpe.net.cable.rogers.com) joined #forth 19:36:00 --- quit: madgarden (Read error: 110 (Connection timed out)) 21:16:42 --- quit: gogonkt_ (lindbohm.freenode.net irc.freenode.net) 21:16:42 --- quit: impomatic (lindbohm.freenode.net irc.freenode.net) 21:16:43 --- quit: KipIngram (lindbohm.freenode.net irc.freenode.net) 21:16:43 --- quit: gnomon (lindbohm.freenode.net irc.freenode.net) 21:16:43 --- quit: tgunr (lindbohm.freenode.net irc.freenode.net) 21:16:43 --- quit: malyn (lindbohm.freenode.net irc.freenode.net) 21:16:44 --- quit: Deformative (lindbohm.freenode.net irc.freenode.net) 21:17:11 --- join: tgunr (n=davec@polymicro.net) joined #forth 21:17:11 --- join: malyn (n=malyn@unaffiliated/malyn) joined #forth 21:17:11 --- join: Deformative (n=joe@c-71-238-45-45.hsd1.mi.comcast.net) joined #forth 21:17:50 --- join: gogonkt_ (n=info@58.248.188.163) joined #forth 21:17:50 --- join: impomatic (n=John@nat67.mia.three.co.uk) joined #forth 21:17:50 --- join: gnomon (n=gnomon@CPE001d60dffa5c-CM000f9f776f96.cpe.net.cable.rogers.com) joined #forth 21:17:50 --- join: KipIngram (n=kip@173.11.138.177) joined #forth 23:11:11 --- join: kar8nga (n=kar8nga@a-39.vc-graz.ac.at) joined #forth 23:25:55 --- quit: kar8nga (Read error: 54 (Connection reset by peer)) 23:29:26 --- join: kar8nga (n=kar8nga@e-19.vc-graz.ac.at) joined #forth 23:54:49 --- quit: kar8nga (Remote closed the connection) 23:55:13 --- join: dkcl` (n=dkcl@metabug/dandersen) joined #forth 23:58:31 --- quit: dkcl (Read error: 60 (Operation timed out)) 23:59:59 --- log: ended forth/09.05.11