00:00:00 --- log: started forth/08.09.30 01:42:52 --- quit: proteusguy (Read error: 110 (Connection timed out)) 01:44:03 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 01:52:02 --- quit: ramkrsna (calvino.freenode.net irc.freenode.net) 01:52:03 --- quit: nighty__ (calvino.freenode.net irc.freenode.net) 01:52:03 --- quit: mathrick (calvino.freenode.net irc.freenode.net) 01:52:05 --- quit: cmeme (calvino.freenode.net irc.freenode.net) 01:52:11 --- quit: crc (calvino.freenode.net irc.freenode.net) 01:52:13 --- quit: Baughn (calvino.freenode.net irc.freenode.net) 01:52:13 --- quit: JasonWoof (calvino.freenode.net irc.freenode.net) 01:52:13 --- quit: erg (calvino.freenode.net irc.freenode.net) 01:52:14 --- quit: proteusguy (calvino.freenode.net irc.freenode.net) 01:52:17 --- quit: ASau (calvino.freenode.net irc.freenode.net) 01:52:18 --- quit: probonono (calvino.freenode.net irc.freenode.net) 02:03:03 --- quit: Malfermi1aKodo (calvino.freenode.net irc.freenode.net) 02:03:03 --- quit: segher (calvino.freenode.net irc.freenode.net) 02:03:03 --- quit: lasts (calvino.freenode.net irc.freenode.net) 02:03:07 --- quit: Fractal (calvino.freenode.net irc.freenode.net) 02:03:07 --- quit: gnomon (calvino.freenode.net irc.freenode.net) 02:03:07 --- quit: xjrn_ (calvino.freenode.net irc.freenode.net) 02:03:09 --- quit: tarbo (calvino.freenode.net irc.freenode.net) 02:03:09 --- quit: kspaans_ (calvino.freenode.net irc.freenode.net) 02:03:09 --- quit: maht (calvino.freenode.net irc.freenode.net) 02:03:09 --- quit: lucca (calvino.freenode.net irc.freenode.net) 02:03:09 --- quit: Deformative (calvino.freenode.net irc.freenode.net) 02:03:10 --- quit: nighty^ (calvino.freenode.net irc.freenode.net) 02:17:02 --- join: JasonWoof (n=jason@unaffiliated/herkamire) joined #forth 02:17:02 --- join: cmeme (n=cmeme@boa.b9.com) joined #forth 02:17:02 --- join: mathrick (n=mathrick@users177.kollegienet.dk) joined #forth 02:17:02 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 02:17:02 --- join: ramkrsna (n=ramkrsna@unaffiliated/ramkrsna) joined #forth 02:17:02 --- join: ASau (n=user@host101-231-msk.microtest.ru) joined #forth 02:17:02 --- join: probonono (n=User@unaffiliated/probonono) joined #forth 02:17:02 --- join: erg (n=erg@li13-154.members.linode.com) joined #forth 02:17:02 --- join: Baughn (n=svein@084202038064.customer.alfanett.no) joined #forth 02:17:02 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 02:17:02 --- join: crc (n=charlesc@pdpc/supporter/active/crc) joined #forth 02:17:02 --- join: Malfermi1aKodo (n=kansu@xdsl-78-34-135-102.netcologne.de) joined #forth 02:17:02 --- join: segher (n=segher@84-105-61-45.cable.quicknet.nl) joined #forth 02:17:02 --- join: xjrn_ (n=jim@c-69-181-213-99.hsd1.ca.comcast.net) joined #forth 02:17:02 --- join: nighty^ (n=nighty@x122091.ppp.asahi-net.or.jp) joined #forth 02:17:02 --- join: lasts (n=lasts@77.207.25.109) joined #forth 02:17:02 --- join: tarbo (n=me@unaffiliated/tarbo) joined #forth 02:17:02 --- join: kspaans_ (i=kspaans@artificial-flavours.csclub.uwaterloo.ca) joined #forth 02:17:02 --- join: maht (n=maht__@85.189.31.174.proweb.managedbroadband.co.uk) joined #forth 02:17:02 --- join: Deformative (n=joe@c-68-62-76-160.hsd1.mi.comcast.net) joined #forth 02:17:02 --- join: gnomon (n=gnomon@CPE001d60dffa5c-CM000f9f776f96.cpe.net.cable.rogers.com) joined #forth 02:17:02 --- join: Fractal (i=frax@institutionalized.s0ciopath.org) joined #forth 02:17:02 --- join: lucca (n=lucca@kuu.accela.net) joined #forth 02:17:02 --- mode: irc.freenode.net set +oo JasonWoof crc 02:17:29 --- quit: cmeme (calvino.freenode.net irc.freenode.net) 02:17:31 --- quit: nighty__ (calvino.freenode.net irc.freenode.net) 02:17:31 --- quit: ramkrsna (calvino.freenode.net irc.freenode.net) 02:17:31 --- quit: mathrick (calvino.freenode.net irc.freenode.net) 02:21:18 --- quit: proteusguy (Connection timed out) 02:21:40 --- join: proteusguy (n=proteusg@ppp-124-120-229-45.revip2.asianet.co.th) joined #forth 02:22:07 --- quit: crc (calvino.freenode.net irc.freenode.net) 02:23:22 --- join: crc (n=charlesc@pdpc/supporter/active/crc) joined #forth 02:23:22 --- mode: irc.freenode.net set +o crc 02:32:53 --- join: ramkrsna (n=ramkrsna@unaffiliated/ramkrsna) joined #forth 02:32:53 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 02:32:53 --- join: mathrick (n=mathrick@users177.kollegienet.dk) joined #forth 02:32:53 --- join: cmeme (n=cmeme@boa.b9.com) joined #forth 02:39:39 --- quit: cmeme (calvino.freenode.net irc.freenode.net) 02:39:39 --- quit: nighty__ (calvino.freenode.net irc.freenode.net) 02:39:39 --- quit: mathrick (calvino.freenode.net irc.freenode.net) 02:39:39 --- quit: ramkrsna (calvino.freenode.net irc.freenode.net) 02:44:21 --- quit: nighty^ (Excess Flood) 02:45:23 --- join: nighty^ (n=nighty@x122091.ppp.asahi-net.or.jp) joined #forth 02:47:41 --- join: ramkrsna (n=ramkrsna@unaffiliated/ramkrsna) joined #forth 02:47:41 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 02:47:41 --- join: mathrick (n=mathrick@users177.kollegienet.dk) joined #forth 02:47:41 --- join: cmeme (n=cmeme@boa.b9.com) joined #forth 02:53:43 --- join: gogonkt`` (n=info@125.34.34.193) joined #forth 03:09:19 --- quit: cmeme (calvino.freenode.net irc.freenode.net) 03:09:19 --- quit: nighty__ (calvino.freenode.net irc.freenode.net) 03:09:20 --- quit: mathrick (calvino.freenode.net irc.freenode.net) 03:09:20 --- quit: ramkrsna (calvino.freenode.net irc.freenode.net) 03:15:08 --- join: ramkrsna (n=ramkrsna@unaffiliated/ramkrsna) joined #forth 03:15:08 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 03:15:08 --- join: mathrick (n=mathrick@users177.kollegienet.dk) joined #forth 03:15:08 --- join: cmeme (n=cmeme@boa.b9.com) joined #forth 03:19:18 --- quit: cmeme (calvino.freenode.net irc.freenode.net) 03:19:19 --- quit: nighty__ (calvino.freenode.net irc.freenode.net) 03:19:19 --- quit: mathrick (calvino.freenode.net irc.freenode.net) 03:19:19 --- quit: ramkrsna (calvino.freenode.net irc.freenode.net) 03:20:38 --- join: ramkrsna (n=ramkrsna@unaffiliated/ramkrsna) joined #forth 03:20:38 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 03:20:38 --- join: mathrick (n=mathrick@users177.kollegienet.dk) joined #forth 03:20:38 --- join: cmeme (n=cmeme@boa.b9.com) joined #forth 03:57:58 --- quit: proteusguy (Read error: 110 (Connection timed out)) 03:59:32 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 04:22:23 --- nick: Malfermi1aKodo -> MalfermitaKodo 04:32:53 --- join: syozh (i=syozh@89.252.12.221) joined #forth 04:33:10 --- part: syozh left #forth 04:35:10 --- join: Malfermi1aKodo (n=kansu@xdsl-78-34-151-107.netcologne.de) joined #forth 04:35:19 --- quit: MalfermitaKodo (Nick collision from services.) 04:35:28 --- nick: Malfermi1aKodo -> MalfermitaKodo 04:38:28 --- quit: JasonWoof (Read error: 113 (No route to host)) 06:40:22 --- quit: nighty__ (Read error: 104 (Connection reset by peer)) 07:02:06 --- nick: ASau -> ASau` 07:27:23 --- quit: proteusguy (Read error: 110 (Connection timed out)) 07:29:07 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 08:13:32 --- join: ASau (n=user@193.138.70.52) joined #forth 08:17:47 --- part: Baughn left #forth 10:04:21 --- quit: ASau` (Read error: 110 (Connection timed out)) 10:34:59 --- join: JasonWoof (n=jason@c-65-96-160-164.hsd1.ma.comcast.net) joined #forth 10:34:59 --- mode: ChanServ set +o JasonWoof 10:48:18 --- join: mark4 (n=mark4@wsip-68-14-227-113.ph.ph.cox.net) joined #forth 11:15:19 --- quit: proteusguy (Read error: 110 (Connection timed out)) 11:15:41 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 11:59:29 right, so... 11:59:30 Thank you for your interest in our SEAforth product. Our suggested retail 11:59:30 price for the S40 evaluation kit is $499 per kit and it will be available in 11:59:30 small quantities on a first come first serve basis in Mid-Oct. 11:59:54 does that mean i can get an eval kit for 40 bucks? 12:00:01 or will i be forced to pay 500 for one 12:00:26 --- join: Baughn (n=svein@084202037181.customer.alfanett.no) joined #forth 12:00:31 * qFox pokes segher 12:00:39 i think you were the one starting this :p 12:05:34 and to prevent confusion, it does not say 40 dollar before, S40 is the model. 12:05:59 thats why i thought an eval thing cost 40 bucks :( 12:25:01 --- quit: ramkrsna (Read error: 113 (No route to host)) 12:31:47 it's called the S40C18, or short "S40", not $40 12:32:19 oh, you figured it out 12:32:29 * segher reads backlog top to bottom ;-) 13:42:41 --- quit: mark4 ("Leaving") 14:06:48 yar, pity though 14:08:47 they try to get commercial customers, they don't really care for hobbyists, eh 14:09:48 i suppose so 14:09:52 at that price :p 14:10:01 i wonder how successfull that'll be though 14:14:23 yeah! I'm getting ubuntu to package gforth with ffcall support 14:14:27 https://bugs.launchpad.net/bugs/269127 14:16:12 --- join: patchwork (n=user@c-67-170-166-6.hsd1.or.comcast.net) joined #forth 14:17:26 JasonWoof, that is -very- nice. Any chance of getting that package to be included with bare Debian as well? 14:19:23 I submitted a bug report to debian about it, linking to the ubuntu one 14:19:37 someone said that the debian gforth maintainer is inactive or something 14:19:40 so it may take a while 14:20:42 if he is inactive, he's not a maintainer. 14:20:49 gnomon: fwiw, it's easy to build your own gforth .deb that has ffcall support. just "apt-get install libffcall1-dev" before building gforth 14:21:16 james said "I just noticed that the Debian maintainer is inactive, so waiting 14:21:17 for a response isn't a good idea." 14:21:44 anybody have a very simple shord example script that uses ffcall? 14:21:51 s/shord/short/ 14:21:57 Sure. 14:22:18 ASau: want to be published on an ubuntu bug report? 14:22:25 library libm libm.so 14:22:25 libm msin sf (fp) sinf 14:22:25 1 >f msin f. cr 14:22:25 libm dmsin df (fp) sin 14:22:28 1 >f dmsin f. cr 14:22:44 : >f s>d d>f ; 14:22:51 Local convenience. 14:23:44 Ah, "require lib.fs" first, of course 14:23:48 cool, thanks 14:23:56 I'll test and submit 14:24:42 --- quit: Baughn ("leaving") 14:24:55 --- join: Baughn (n=svein@084202037181.customer.alfanett.no) joined #forth 14:27:59 Hey all, I'm just starting to learn forth, going through the exercises in the "real time forth" paper, and the first ones are writing reverse3 and reverse4 ( a b c -- c b a ) and ( a b c d -- d c b a ). Seeing that I could just say "1 roll 2 roll" for reverse3 and "1 roll 2 roll 3 roll" for reverse4, I've been trying to make a general reverse function ( n -- ) that reverses the top n elements on the stack. I looked up the recursion 14:27:59 syntax and came up with something like : reverse ( n -- ) dup 0> if 1 - recurse (???) roll else drop then ; but I am trying to figure out how to get the original n back on the stack so that it can be used as an argument to roll (hence the ???). I'm pretty sure I'm going about this the wrong way (trying to program like scheme or something) and I'm wondering what is the forth way to do this? This would help me quite a bit to wrap my 14:28:00 mind around this crazy language. 14:28:44 Don't use "roll" unless it is absolutely necessary. 14:28:47 Thanks for reading that got kind of long 14:29:01 ? Why not? 14:29:19 It is very inefficient. 14:29:36 Not to mention it is useless at the same time. 14:29:53 Ah, okay. Yes the whole implementation revolves around roll, so there has got to be a better way then 14:29:58 ASau: useless? 14:30:03 Yes. 14:30:04 reversing the top N stack elements is "slow" and "useless" anyway 14:30:15 too bad you need it sometimes 14:30:19 JasonWoof, I'm less concerned about being able to use ffcall - as you say, building my own GForth is very easy - than I am in having the word be available in the default installation. 14:30:27 segher: example? 14:30:29 segher: Ya, I just saw a pattern and was trying to abstract it, as an exercise for myself 14:30:33 That's why I really appreciate your package work, there. 14:30:58 patchwork: first rule of Forth programmer: don't abstract. 14:31:06 asau: you need it _very_ sometimes :-) 14:31:28 segher: please, bring _any_ usage example, I don't believe you. 14:31:29 i used it in the OF client interface implementation once 14:31:38 ASau: ??? I thought that was the whole point of programming :) 14:31:55 segher: I do need to reverse 3 or 4 top cells, but that's all. 14:32:00 I mean, I see a reverse3 and I see a reverse4 and I think, "what about reverse?" 14:32:18 patchwork: the point of programming is automatizing human work. 14:32:34 asau: it was an indeterminate number of cells, in my case 14:32:42 patchwork: it isn't in writing something abstract just for the sake of it. 14:33:09 and yes, i could have worked around it just fine, put the params on the stack in the correct order in the first place ;-) 14:33:32 segher: alright, it is extremely rare then :) 14:33:41 i made sure to make my implementation of "reverse" O(n**3) as well :-P 14:33:57 since my "roll" is O(n**2) already 14:34:39 ASau: Haha, yes okay, granted. But abstraction is the means by which work is automatized. 14:34:43 You had the stack in memory, then why didn't you use it? 14:35:08 asau: is that to me? 14:35:14 ASau: The whole act of defining a word, now we don't have to type all those instructions. That is abstraction, no? 14:35:18 patchwork: it is only one of means, and it works only when you have to do similar things many times. 14:35:23 segher: yes. 14:35:39 asau: the stack isn't directly addressable, in the VM i used there 14:35:40 segher: isn't OF 68K/PPC? 14:35:50 this one is portable 14:36:01 OF is arch independent, anyway 14:36:13 some implementations are PowerPC only, sure 14:36:15 like apple's 14:36:17 segher: Alright. 14:36:40 and, anyway: it is _fine_ with me if roll and reverse are dog slow 14:36:52 you shouldn't use them anyway eh :-) 14:37:06 patchwork: and since arbitrary reversal is extremely rare, abstraction isn't the way to go here. 14:37:32 in the context of OF, "slow" doesn't matter anyway: you're waiting on I/O devices all the time, _that_ is the slow part 14:37:57 asau: oh, writing "reverse" is a nice finger exercise 14:38:09 patchwork: sorry you got deluged with commentary. fiddling with the ordering of the stack (going deeper than the top two elements) is generally considered bad form. 14:38:40 patchwork: it's generally held that you're better off (both in terms of productivity and your own education) figuring out how to do it so the stack is mostly in the right order already 14:39:59 : reverse 0 ?DO i roll LOOP ; 14:41:18 JasonWoof: I appreciate the prespective, I was just trying to figure it out as a way to learn the language. It is good to know that that is the approach to the stack, I will strive to write my code that way. 14:41:25 Sure, but it is slow for N large enough. :) 14:41:51 patchwork: imagine simple task and try to solve it in Forth. 14:42:02 just use a 5 element stack, slowness problem solved. 14:42:13 heh :-) 14:42:52 Yes, but you'll be unable to solve even simple tasks, like LU decomposition or numeric integration. 14:43:17 but at least it'll be fast 14:43:18 patchwork: you can do it with just these three words: swap >r r> 14:43:18 All your stack will be eaten by parameters. 14:43:27 sacrifices have to be made, sir! 14:43:30 patchwork: basically solving the towers of hannoi 14:44:09 JasonWoof: Ah, but I had seen all the warnings about the return stack, so was trying to avoid them. Many things to beware of! 14:44:13 yeah, toh is a good stack learning assignment 14:44:14 swap is evil. over dup r@ >r r> nip drop rdrop are the "basic pieces" :-) 14:44:44 ??? Now swap is evil too? 14:44:48 patchwork: as an exercise it's fun, just don't do that in practice 14:44:56 sigh. 14:45:05 aye, just make use of whats there 14:45:13 try to avoid rot and uh, the other one 14:45:14 JasonWoof: Definitely, I got that now :D 14:45:20 patchwork: nah, i was sort-of joking. use swap in your programs whenever you feel like it 14:45:21 patchwork: the return stack is very powerful. learn to use it, and learn to be careful with it :) 14:45:36 swap isn't nice for hardware, that's all 14:45:48 hm, what was the other one again... ROT and .. 14:45:57 RETURN the RETURN stack to its original state before you RETURN 14:46:03 -ROT 14:46:21 basically just try to get everything in the right order to begin with as much as you can 14:46:35 ROT and -ROT are bad. PICK and ROLL are worse. and SWAP is evil 14:46:37 naw, there was rot and ... meh. whatever. try not to use rot so much. 14:46:46 oh, pick and roll 14:46:54 very few people manage to do this enough to avoid using swap much 14:47:08 don't use rot at all if you can help it 14:47:11 you shouldn't avoid SWAP in your programs, really 14:47:15 aye, dont go out on a limb for avoiding them (except perhaps as an excercize :) 14:47:26 segher: if you can do it with or without swap, go without 14:47:31 sure 14:47:33 segher: I'm not suggesting that you try to never use it 14:47:42 I'm just saying, try to have as little stack twiddling as you can 14:47:47 but don't go overboard 14:47:53 Haha, this is great. Being a noob is bewildering :D 14:47:55 overboard would be going way out of your way to avoid a swap 14:47:58 oh, i actually do avoid it myself, but that's just me being stubborn 14:48:16 But yes, I see, get the stack right and you won't need the fiddling words 14:48:21 segher: it's more than being stubborn, it teaches you a great deal, and often makes more readable programs 14:48:22 i start every second word with >R as well :-) 14:48:28 sure 14:48:40 oh, >r isn't any better than swap 14:48:43 OTOH, a SWAP can make things more readable as well 14:49:05 segher: Really? I wondered about the >R, that was how I first thought to solve the problem. 14:49:08 jasonwoof: i have to deal with four or six arguments a lot 14:49:27 _something_ needs to give 14:49:41 patchwork: have you written reverse3 with SWAP >R and R> yet? 14:49:51 reverse3 is quite straightforward with those 14:49:56 Ah no, I'll do that now 14:49:57 reverse4 is a bit ugly 14:50:05 :p 14:50:09 segher: yeah, I use "pluck" (2 pick) extensively. 14:50:17 patchwork: be sure to test it in a word, you can't use >R or R> interractively 14:50:24 it's called UNDER in my VMs 14:50:39 isnt 2 pick OVER ? 14:50:47 1 pick is OVER 14:50:50 oh, right 14:50:52 0 pick is DUP 14:50:54 2 pick is rot? 14:50:54 man its been a while 14:50:55 :) 14:51:01 2 ROLL is ROT 14:51:16 or was that 3 ROLL ? 14:51:23 Actually yeah, any exercises would be great. I always learn best by writing as many things as I can. What are the best exercise collections or tasks for learning forth? 14:51:27 see? don't use ROLL :-) 14:51:44 oh, pick leaves the stack item there, and makes you a copy? 14:51:46 2 roll 14:51:47 "1 roll" = "noop". 14:51:55 1 roll = swap 14:52:00 0 roll = noop 14:52:08 patchwork: try writing PICK and ROLL using just the stack (no memory access); now do the same, but without using LOOP 14:52:21 Hm! 14:52:34 Hey and I'm the noob! 14:52:42 patchwork: I don't know of any, but I always recommend "Starting Forth" as a good learner book 14:53:00 patchwork: it's been converted to a set of free webpages if you prefer to view it that way 14:53:09 I forget if there's exercises in it 14:53:23 if you want to learn how to deal with large number of stack args, write something involving text strings 14:53:29 Ya I got that one, I'm going through the "real time forth" book right now, which is more along the lines of something I would like to build, and it seems to have some pretty good exercises 14:53:36 patchwork: I'd be happy to dream up challenges for you 14:53:58 cool 14:54:01 I haven't read that one 14:54:03 Yeah if you can think of any good ones I'd be all for it 14:54:15 patchwork: let's see your reverse3 first! :) 14:54:22 Something that demonstrates the "forth" way, if there is such a thing 14:54:24 oh, here's a good exercise: write SWAP without using SWAP :-) 14:54:44 JasonWoof: Ya here I am jabbering away, not doing my exercises :D 14:54:44 I don't think this is good exercise. 14:54:54 heh 14:55:27 segher: now that's just mean (and stupid) 14:55:41 but there are so _many_ ways to do it! 14:56:31 oh btw, is there a well-known name for : ??? ( a b -- a a b ) ... ; 14:57:36 :reverse3 swap >R swap R> swap ; 14:57:40 Is that what you had in mind? 14:57:55 There might be an easier way to do that... 14:58:14 sounds like it. that's SWAP ROT ; the other way is -ROT swap 14:59:00 well, the same way :-) 14:59:47 patchwork: yay! 15:00:09 patchwork: that's the easiest way with the words I told you to use :) 15:00:26 patchwork: have you gotten into looping constructs yet? 15:00:27 Cool, this stuff is fun 15:00:37 JasonWoof: No not at all, just started today 15:00:50 patchwork: ok, recursion is more fun anyway 15:01:14 patchwork: you know if/then? 15:01:23 JasonWoof: Ya, I've always preferred recursion, don't really know why, seems more fundamental or something 15:01:33 Yeah I got IF, but why is True -1? 15:01:37 patchwork: it's prettier I think :) 15:01:37 That threw me for a loop 15:01:49 TRUE has to return something 15:01:51 --- quit: proteusguy (Connection timed out) 15:02:00 it's -1 because that's all 1 bits 15:02:09 Oh, okay that makes sense then 15:02:14 it makes it convenient sometimes to mix boolean and bitwise logic 15:02:21 --- join: proteusguy (n=proteusg@61.7.144.97) joined #forth 15:02:23 i'm off 15:02:24 gnite 15:02:59 patchwork: usually makes it so the difference between boolean "and" and bitwise "and" usually doesn't matter 15:03:13 gnite qFox 15:03:37 Yeah actually now that I know it's all ones that makes a lot of sense 15:03:50 --- quit: qFox ("Time for cookies!") 15:04:38 patchwork: make me a word that takes a number, adds 1 to it, then squares the result 15:06:28 Alright, : spo ( n -- n ) 1 + dup * ; 15:06:38 cool 15:07:05 two little notes here: 1) there's usually a word 1+ which does the same as "1 +" but is faster, and quite readable 15:07:21 2) for better readability, factor out "dup *" 15:07:34 so : square dup * ; ? 15:07:37 it doesn't take long to figure out that that squares TOS, but it's more readable 15:07:47 usually this reads better: : squared dup * ; 15:08:13 so : spo ( n -- n ) 1+ squared ; 15:08:17 That is pretty nice 15:08:27 BTW, I highly encourage factoring, so don't be afraid to give me 2+ definitions when I ask for code to do one thing :) 15:08:30 it does exactly what it looks like 15:08:34 very nice 15:08:35 Gotcha 15:08:43 patchwork: now you don't need to comment it :) 15:09:11 ok, now a word that does that 4 times 15:10:29 recursive? Or loop? Or just "spo spo spo spo"? 15:10:43 spo spo spo spo 15:10:50 : spo4 spo spo spo spo ; 15:11:29 it's very readable, and generally more efficient than a loop in terms of execution speed 15:11:50 pretty hard to have a bug there 15:11:57 you familiar with fibbinocci sequence? 15:12:05 Ya pretty fond of it 15:12:11 cool, it's fun to play with 15:12:21 start with 0 1 on the stack 15:12:28 That sounds like a good plan 15:12:55 I'll see if I can pull this off 15:13:06 make a word that prints the next fib and updates the stack, so you can call your word again to print the next one 15:13:51 then you can make : fib5 fib fib fib fib fib ; to print "1 1 2 3 5" 15:14:14 you can start with 1 0 if that's easier 15:15:53 Hmm, so here's one way -- : fib 2dup + rot drop dup . ; 15:16:04 The rot drop is questionable though 15:16:20 you'll need EXIT to do recursion. that returns/exits from the current definition without ending it like ";" does. so you can do eg: : foo 10 > if exit then 4 + foo ; 15:16:27 hi 15:16:48 Hey slava 15:16:49 patchwork: yeah, see if you can do it without 2dup or rot. you'll probably want to use OVER 15:17:05 Ah okay that would be better 15:17:13 patchwork: OVER is very useful and totally PC 15:18:24 what is "PC" ? 15:18:34 patchwork: in these simple examples, I have an idea of how simple it can possibly get, but in general a good guideline, is that you should be able to read your definitions and be clear about exactly what they do without needing to make a diagram 15:18:40 lasts: politically correct :) 15:18:48 :-° 15:19:04 slava: I was learning factor and then realized I needed to learn forth first :D 15:19:18 hehe 15:19:21 there's no prerequisite like that 15:19:34 slava: do you have nice newbie litterature? 15:19:56 docs.factorcode.org 15:20:11 150mb of docs :) 15:20:21 damn 15:20:38 slava: Sure, just wanted to start at the metal so that I appreciate the abstractions when I get them :) 15:21:43 slava: Nice work on the web stack by the way, definitely the next platform I'm looking into 15:23:14 slava: It is good to get all the useful libraries out there since lack of libraries is always everyone's main complaint about non-mainstream languages 15:23:33 People are still giving lisp hell about that, even though it's largely untrue now 15:24:01 Now there is no reason to not use factor, other than fear :) 15:24:42 that "fib" example is a great use for TUCK , the most under-valued stack manipulator of all :-) 15:25:03 tuck... 15:25:17 : tuck ( a b -- b a b ) 15:25:27 Ha, exactly what I was looking for 15:26:30 Now it is just : fib tuck + ; 15:26:35 or : fib tuck + dup . ; to print 15:26:45 tuck . + 15:28:07 It the dual of 'over' 15:28:14 sort of 15:28:27 it's the brother of DUP and DUP>R as well 15:39:54 Just figured out fac too 15:39:59 : fac ( n -- n! ) dup 1 > if dup 1- recurse * then ; 15:40:31 lots of dup'ing 15:41:12 : fac ( n -- n! ) 1 [a,b] product ; 15:41:13 :-) 15:41:58 Yo, what? 15:42:05 Oh, [a,b] creates a range 15:42:12 I see 15:44:02 tuck + works :) 15:45:21 Yeah, got that one :) But if you start with 1 0 on the stack you can say "over + swap" 15:45:30 Which is I think what you were getting at? 15:46:18 yeah, in this case, it just as easy with the stack either way 15:46:31 starting with 0 1 you do "swap over +" 15:46:45 starting with 1 0 you do "over + swap" 15:47:05 the former has the advantage that you can use the fairly common "tuck" 15:47:18 : tuck swap over ; 15:47:24 Yeah "tuck" is just "swap over" 15:47:26 Exactly 15:47:29 beat me too it 15:47:44 a similar word (both in popularity and usefulness and in it's not being included by default in most forths) is nip 15:47:51 : nip ( a b -- b ) swap drop ; 15:48:10 COOL 15:48:14 Man this stuff is great 15:48:48 in some cases, when you consider different stack arrangements, one method is drastically less convenient, so it's good to have this practice of considering which is better 15:50:41 you know about "garland" fractals? 15:51:00 I know I'm just a beginner but there is something great about the simplicity of this approach, just naming the function and letting it deal with the stack, no passing variables around 15:51:16 No what are "garland" fractals? 15:52:27 yeah 15:52:32 factoring is what makes forth cool 15:52:39 that and it can read easy 15:52:59 I personally like how you can read it left to right without having to look ahead to see what something means, or what order stuff is computed 15:53:24 as apposed to say C/C++ where you have operator precedence 15:54:24 eh, can't find info on garland atm 15:55:08 Yeah all that extra complexity is supposed to make things "more intuitive" or something, but when you are trying to figure out what something is doing you basically have to replicate the process of interpretation or compilation in your head, to a certain degree. 15:55:14 patchwork: ok, now something more complex: : factors ( n -- ) 15:55:25 it should print all factors of n, then exit 15:55:45 Alright, that one sounds good. 15:56:15 use recursion, not loops 15:57:30 don't use rot 15:57:42 or tuck/pull/pick/roll/icky stuff 15:57:47 well, more has been done with C++ than forth though 15:58:05 for stack manipulation stick to: dup over swap tuck nip >r r> 2dup 15:58:22 slava: yep 15:58:32 i'm still waiting for a web browser written in forth :) 15:58:34 slava: it's still a pita 15:59:00 slava: I tried to get people together to write one 15:59:12 slava: didn't get very far before everybody stopped coding 15:59:32 slava: I ended up writing a very nice unit testing thing though 16:00:34 kc5tja added some functions for structure handling and ascii windows and such that I have not fully explored 16:01:37 well, i think you'd have fundamental difficulties using forth to write something like webkit or mozilla 16:02:06 slava: in what way? What is the obstacle? 16:05:31 I see two major hurdles: 16:05:58 1) I generally think in terms of having to start from the ground up (although there is code available for use) 16:06:46 2) In my experience, there aren't many forth programmers that want to cooperate on a single project. Maybe there are some that aren't already working with slava :) 16:07:25 well, you probably want a type system for larger apps 16:07:29 3) Something like webkit must be damn fast, building in optomized native code generation would be a major project 16:07:49 #3 is not such a major hurdle 16:08:43 well, it makes it so working "from the ground up" is really starting from scratch 16:08:55 writing the compiler and everything 16:09:11 at least we're keeping the drivers/OS :) 16:09:30 the bigger your codebase, the more help you need from the computer in enforcing abstraction boundaries 16:10:37 --- join: tathi (n=josh@pdpc/supporter/bronze/tathi) joined #forth 16:10:37 --- mode: ChanServ set +o tathi 16:10:40 Couldn't you write a type system in forth? 16:11:03 See StrongForth.f recently discussed on c.l.f 16:11:11 At least for the critical application-level types 16:11:34 stack elements are essentially type-less 16:11:41 unless you want a second stack that holds the types or something 16:11:43 Not in StrongForth :-) 16:11:46 or if you store everything as an object 16:12:03 major slowdown either way 16:12:24 more practical would probably be an object system 16:12:28 SF does indeed maintain a typestack, but it only deals with types at compile time. 16:12:43 so all objects have some common "type" field that is accessed in the same way 16:12:59 TreyB: fancy 16:13:09 ok, I gotta get to work. use my nick to get my attention 16:13:15 TreyB: Interesting, so is it written in forth? 16:13:20 No. I don't have time to chat about it right now (meeting to attend) but StrongForth deals with. 16:13:27 JasonWoof: Thanks a lot for your help 16:13:40 patchwork: Yes, StrongForth.f in ANS Forth. Google for it. 16:14:09 TreyB: Cool, thanks for the lead 16:14:11 http://home.vrweb.de/stephan.becher/forth/ 16:14:53 http://home.vrweb.de/~stephan.becher/strongforth.f/ 16:15:23 last I checked strongforth didn't deal with any of the interesting cases (like ?dup) though 16:15:39 Looked like it was just the obvious implementation of tracking types while compiling 16:15:55 haven't gotten time to look at the new one yet though... 16:16:30 strongforth can't express ?dup 16:16:54 that's what I said 16:17:01 er...what I meant, anyway. 16:17:20 factor can't either 16:17:26 really? 16:17:49 it won't pass the stack checker because of an unbalanced conditional 16:17:59 Huh. 16:18:28 So does factor have a type system then? 16:18:32 I guess I'll have to go play with my type inference code some more; it didn't seem difficult to me. 16:18:36 only for the number of inputs and outputs 16:18:43 it doesn't track the types of values, like strongforth does 16:18:43 I admit I only played with very simple cases... 16:19:12 type inference only gets tricky when you have higher order functions 16:19:18 otherwise it can be done in linear time with a simple algorithm 16:19:27 ok, that's what I though 16:19:29 thought 16:45:53 JasonWoof: Alright here you go, messed around with it a lot but this looks okay 16:46:10 : half>= ( a b -- a b flag ) 2dup swap 2 / <= ; 16:46:27 : fcts ( n x -- ) half>= if 2dup mod 0= if dup . then 1+ recurse else 2drop then ; 16:46:49 : factors ( n -- ) 1 fcts ; 16:47:09 As long as a number is not a factor of itself 16:48:15 yikes :) 16:48:20 I could do away with the half>= and replace it with "2dup >" but it would be less efficient 16:48:22 * JasonWoof tests 16:49:06 Still, I know there are better ways to find the factors of a number :) 16:49:09 patchwork: you prefer recursion to loops? 16:49:10 looks good 16:49:10 MUCH better ways 16:49:13 printing 1 is silly 16:49:19 tathi: Yes 16:49:42 tathi: last I checked he hadn't learned loops yet anyway :) 16:49:44 JasonWoof: Yeah I know, it's still a factor though right? :) 16:49:57 just curious... 16:50:02 patchwork: ok, I have some feedback: 16:50:03 you could change it to ": factors 2 fcts ;" 16:50:19 JasonWoof: Yeah that's what I'm here for 16:50:38 1) it's customary to have words consume their arguments, so you should probably do "2dup half>=" instead of having the 2dup inside half>= 16:50:54 Yeah I wondered about that, wasn't sure which way to go 16:51:10 2) when you can do so easily, don't use "else" eg your "else 2drop then" can be rewritten "then 2drop" 16:51:40 I think that is necessary though because it only happens if the condition didn't work... 16:51:51 3) it would probably be much simpler to print the higher factors first 16:52:03 er... "exit then 2drop" ? 16:52:04 then you don't have to check for n/2 as end point, you can just check for 1 16:52:33 tathi: think this is correct: recurse then 2drop ; 16:52:42 JasonWoof: I did it descending first, and then reread your statement of the exercise and interpreted it as starting from 1 16:52:51 oh, sorry 16:53:09 patchwork: glad you're thinking outside the box 16:53:41 Forth is way fun 16:53:50 I'm still having trouble understanding half>= 16:53:57 I think I'm hooked 16:54:18 ? It just checks to see if the second argument is less than or equal to half the first argument 16:54:29 patchwork: just out of curiosity, where are you coming from? (programming languages, etc.) 16:54:40 how about replacing half>= with : fcts-done? ( a b -- flag ) 2 * > ; 16:55:18 : fcts ( n x -- ) 2dup fcts-done? if exit then ... 16:56:00 tathi: I've done a lot of programming in all kinds of languages, professionally in C++ and ruby, love scheme, haskell and erlang 16:56:11 messed around with J and m4 16:56:15 cool 16:56:29 have a pile of python code that I never mess with anymore 16:57:18 JasonWoof: fcts-done? looks good 16:58:38 patchwork: you're half>= is buggy 16:58:41 try this: 16:58:42 3 1 half>= . 16:59:16 it's not a problem for factors, since odd numbers don't have a factor at n/2 anyway 16:59:25 but it's always good to have all your words do what it looks like they do 16:59:35 Ah yes, good catch 16:59:48 I thought that wasn't an issue because of the application but yes your right 16:59:51 gotta watch out for rounding errors 17:00:10 you can usually avoid those by multiplying instead of dividing 17:00:26 or in other cases, doing the stuff that makes the numbers bigger before the divides 17:00:49 Yes since multiplying doesn't have rounding :) 17:01:17 and it even avoids the swap, which makes the < much less confusing 17:01:52 my first large programming project was a mandelbrot/juila set fractal generator 17:02:27 I spent a long time optomizing before I realized that I could replace: if(sqrt(x*x + y*y) < 2) 17:02:39 with if(x*x + y*y < 4) 17:03:00 ok, I'm going dancing 17:03:02 Yeah that is a good tip 17:03:06 ttyl I hope 17:03:11 Thanks again JasonWoof 17:03:23 patchwork: the real test of good code is "can you read it a month later" 17:35:52 --- join: Malfermi1aKodo (n=kansu@xdsl-78-34-134-71.netcologne.de) joined #forth 17:40:38 --- quit: tathi ("leaving") 17:42:29 --- join: nighty__ (n=nighty@210.188.173.246) joined #forth 17:47:08 --- quit: MalfermitaKodo (Connection timed out) 18:17:41 --- quit: madgarden ("?OUT OF DATA ERROR") 18:18:14 --- join: snowrichard (i=richard@12.169.182.169) joined #forth 18:18:29 hello 18:18:30 --- join: madgarden (n=madgarde@CPE001d7e527f89-CM00159a65a870.cpe.net.cable.rogers.com) joined #forth 18:19:16 !seen crc 18:19:25 I'm here 18:19:30 hey 18:19:50 I did some stuff on my server and like deleted your account - 18:20:18 and we had a major power outage from the IKE storm 18:20:24 5 days 18:20:27 ok. that would explain why I wasn't able to connect last week... 18:20:28 ouch 18:20:44 yeah lost fridge full of food 18:21:19 anyway if you want I can set one up again, /msg me the password you want 18:21:36 snowrichard: You live in the Houston area? 18:21:45 Just 250 miles north 18:21:58 "Just" :-) 18:22:12 * TreyB lives SSE of Houston. 18:22:29 I used to live in houston in a crack infested low rent apartment it was horrible 18:24:11 I'm writing yet another interpreter, I never got the last version of mine working quite like I wanted 18:26:32 its not exactly forth like in that I have a stack cell that is a union of either int, long, float, string ptr, or other ptr. 18:26:47 and a tag for type 18:27:47 brb crc I'll fix that acct now 18:28:03 thanks 18:35:49 --- quit: snowrichard ("Leaving") 18:36:52 --- join: snowrichard (i=richard@12.169.182.169) joined #forth 18:37:07 lost this window somehow 18:41:16 --- quit: snowrichard ("Leaving") 18:47:45 --- join: snowrichard (i=richard@12.169.182.169) joined #forth 18:48:04 crc the pdf alpha arch handbook is in your home and you have a mail :) 18:51:24 --- quit: snowrichard (Client Quit) 19:19:17 ahhh 19:33:27 hi guys 20:06:22 --- quit: crc ("Thunderstorms...") 21:06:58 --- quit: ASau (Remote closed the connection) 21:07:14 --- join: ASau (n=user@193.138.70.52) joined #forth 22:13:32 --- join: ASau` (n=user@host75-231-msk.microtest.ru) joined #forth 22:49:16 --- quit: JasonWoof ("off to bed") 23:59:59 --- log: ended forth/08.09.30