00:00:00 --- log: started forth/18.09.05 00:06:39 dave9: 00:19:14 hi yunfan 00:37:46 dave9: hi 00:44:41 --- join: mtsd (~mtsd@77.110.61.100) joined #forth 00:53:50 --- join: ncv (~neceve@90.207.222.160) joined #forth 00:53:50 --- quit: ncv (Changing host) 00:53:50 --- join: ncv (~neceve@unaffiliated/neceve) joined #forth 01:21:24 I'll be at the Retro Computer Festival in Cambridge on 15th September if anyone else is planning to go http://www.computinghistory.org.uk/det/43210/Retro-Computer-Festival-2018-15th-16th-September/ 02:03:29 --- quit: ashirase (Ping timeout: 244 seconds) 02:10:26 --- join: ashirase (~ashirase@modemcable098.166-22-96.mc.videotron.ca) joined #forth 03:04:29 --- quit: mtsd (Quit: Leaving) 03:24:36 --- join: [X-Scale] (~ARM@46.50.5.2) joined #forth 03:25:31 --- quit: X-Scale (Ping timeout: 246 seconds) 03:25:31 --- nick: [X-Scale] -> X-Scale 04:09:49 --- quit: pierpal (Quit: Poof) 04:10:08 --- join: pierpal (~pierpal@host60-229-dynamic.16-87-r.retail.telecomitalia.it) joined #forth 04:20:51 --- quit: nighty- (Quit: Disappears in a puff of smoke) 04:44:54 --- quit: lonjil (Ping timeout: 252 seconds) 05:09:49 --- join: lonjil (~quassel@2a02:418:6050:ed15:ed15:ed15:e741:32d6) joined #forth 05:25:02 --- join: nighty- (~nighty@s229123.ppp.asahi-net.or.jp) joined #forth 06:22:57 --- quit: pierpal (Quit: Poof) 06:23:16 --- join: pierpal (~pierpal@host60-229-dynamic.16-87-r.retail.telecomitalia.it) joined #forth 07:00:49 --- quit: dave9 (Quit: one love) 07:00:59 https://tinyletter.com/jamesbowman/letters/upduino-a-9-99-fpga <- perhaps a semi good FPGA to play around with to implement your own dual stack machine 07:03:00 --- join: gravicappa (~gravicapp@ppp83-237-166-44.pppoe.mtu-net.ru) joined #forth 07:42:27 --- quit: pierpal (Quit: Poof) 07:42:46 --- join: pierpal (~pierpal@host60-229-dynamic.16-87-r.retail.telecomitalia.it) joined #forth 08:16:59 Zarutian: i just got one of those. Started working on porting the raspberry pi programming method to linux/c.h.i.p. 08:24:25 --- quit: gravicappa (Ping timeout: 246 seconds) 08:26:29 --- join: [1]MrMobius (~default@c-73-134-82-217.hsd1.va.comcast.net) joined #forth 08:29:28 --- quit: MrMobius (Ping timeout: 240 seconds) 08:29:28 --- nick: [1]MrMobius -> MrMobius 08:39:17 unrznbl[m]: what is the raspberry pi programming method? 09:43:59 john_metcalf: Interesting 10:26:12 --- quit: ncv (Ping timeout: 252 seconds) 10:54:26 --- quit: pierpal (Quit: Poof) 10:54:47 --- join: pierpal (~pierpal@host60-229-dynamic.16-87-r.retail.telecomitalia.it) joined #forth 11:28:14 --- join: gravicappa (~gravicapp@ppp83-237-167-233.pppoe.mtu-net.ru) joined #forth 12:50:39 --- join: dddddd (~dddddd@unaffiliated/dddddd) joined #forth 13:09:47 --- join: pierpa (5710e53c@gateway/web/freenode/ip.87.16.229.60) joined #forth 14:11:47 --- quit: gravicappa (Ping timeout: 272 seconds) 14:22:35 --- quit: Zarutian (Read error: Connection reset by peer) 14:23:50 --- join: Zarutian (~zarutian@173-133-17-89.fiber.hringdu.is) joined #forth 16:09:48 --- quit: epony (Ping timeout: 240 seconds) 16:38:57 --- quit: nighty- (Quit: Disappears in a puff of smoke) 16:42:49 --- join: Guest23783 (~c@177.36.189.110) joined #forth 16:44:46 Hi 16:45:02 I am trying to run a simple program. 16:45:26 Could u guys help me out? 16:45:34 I'll give it a look see. 16:46:26 It's intended to read two numbers and do some operations on them. 16:46:38 This is what I came up with: https://privatebin.net/?bfdf4ebdc53f07a0#vibH6KIRGIT1qjwwy8KzSqSSAdU5CxwcR+NakqZsj0c= 16:46:43 Ok. One sec. 16:47:11 You need spaces after your ." words. 16:47:23 But not before the closing quotes. 16:47:56 I'm not really sure why you have some of that in there. 16:48:10 Tell me what this line is supposed to do: 16:48:12 s. n1 n2 +. 16:49:05 If n1 and n2 are variables, then n1 n2 + . (with all the words space-separated!) would add the ADDRESSES of n1 and n2 and print that sum. 16:49:11 To add the numbers themselves you want 16:49:15 n1 @ n2 @ + . 16:49:36 And I don't know what your s. at the beginning of that is supposed to print - I guess I'd expect it to take an address from the stack and print a string from that ddress. 16:49:38 Add them. 16:49:45 And display. 16:49:48 But I don't see that you got an address onto the stack for s. to use. 16:50:08 What are you expecting @n1 and @n2 to do? 16:50:49 To sum them and show on the screen. 16:51:41 Well, those aren't standard Forth words. You could name a word @n1 or @n2 if you wanted to, but you'd have to give a definition for those. 16:51:47 Definitions, rather. 16:51:59 Your biggest problem is that you don't have spaces in many places that you need them. 16:52:08 Forth words have to be space-separated from one another. 16:52:22 I see, so this "@" works as a dereference. 16:52:45 Yes - @ expects an address on the stack - it consumes that address and replaces it (on the stack) with the contents of that address. 16:52:58 It doesn't operate on a variable name, though. 16:53:12 you would put numbers into n1 and n2 with n1 ! and n2 ! 16:53:31 Then you can fetch the numbers with n1 @ or n2 @ 16:53:46 So n1 @ n2 @ + . will print their sum. 16:54:07 n1 @ n2 @ / . would print the quotient, etc. 16:54:26 Words like + and / and other such operators operate exclusively on the stack. 16:54:38 They don't care how the numbers on the stack got there. 16:55:35 When you define a word with VARIABLE (e.g., variable n1 ) that creates a dictionary entry bearing that name and allocates one cell of storage associated with it. 16:55:48 Executing that word name (n1 or n2) places the address of that allocated cell on the stack. 16:56:38 Aside from your missing spaces, an a misunderstanding about how @ works, the remaining problem is the s. 16:56:45 I don't see that you've given anything for it to work on. 16:57:04 Maybe you thought it was need to print the result of the stuff you typed after it? 16:57:12 The . word prints the number that's on top of the stack. 16:57:30 Exactly that. 16:57:30 I think that's the only printing operations you need aside from your "section labeling" ." sequences. 16:58:09 Ok, so put the spaces in, use ! to store numbers in the variables, use @ to get the numbers onto the top of the stack, and get rid of the s. 16:58:15 I think you'll have something that will run then. 16:58:20 And welcome to Forth. :-) 17:01:11 Thanks mate. =D 17:01:35 Just did. I have to run to the supermarket now, soon I will be back. 17:28:08 --- join: epony (~epony@unaffiliated/epony) joined #forth 17:48:46 --- join: nighty- (~nighty@kyotolabs.asahinet.com) joined #forth 18:23:00 I'm back. 18:23:58 It stayed like this: https://privatebin.net/?6a312cc613b78c3e#sTVWec5taBvUL3F8IMBKQJIjo9b1pPJ6cutPzZW46Lo= 18:24:17 But it gives me the following error: https://privatebin.net/?6d2117d83daf37da#uEePVpWrb+c+9DKzVOmJ6H19ZH+6kdgk4xS9dWm3+7I= 18:27:45 you'll need a space between the + and the . 18:28:41 Oh, there too. 18:31:42 something like https://privatebin.net/?c1fb9c1aa2ce5778#nKb740rYAgn9gFIdSNZhrnU6gG7VvNo8ZOL3pUEfnzk= (/. to / . and some fixes in the ? word) 18:34:28 https://privatebin.net/?041c066155e1a5fc#jOywa3fVeJsyvBzJNyF/aDprc/GLPxoEMjUw0FL/q8M= (more fixes to ? - need to use @ to get the values in n1 and n2) 18:34:53 It works o/ 18:35:08 Thank you @crc 18:37:33 Do u know if it's possible to do operations on more than two numbers at a time? 18:39:18 I mean, multiple operations. Like (a + b - (a * b))/3 18:40:06 It still just two numbers anyways. 18:43:19 Nevermind, found another way to do it. 18:43:46 Just one more doubt. 18:44:28 There's a formula translator for forth at http://galileo.phys.virginia.edu/classes/551.jvn.fall01/programs.htm (I've never used it, translating to rpn is pretty straightforward) 18:44:39 How would I replace the hard coded numbers by runtime input? 18:45:31 That is handy, thanks. I'm gonna keep it. 18:47:11 I saw that "accept" is used for strings only. 18:50:38 I'm not sure the best way to do this 18:57:44 Ok. 18:58:57 this works in gforth: 18:59:09 : get-number pad 80 accept pad swap s>number drop ; 19:02:50 s>number isn't a standard word though. 19:03:44 I got this error: https://privatebin.net/?e58bd73c07dc66db#6/0cQGuRrchb0YVvyQ2leLQIuji1tHqTM+VD9XTdjs0= 19:04:01 I switched the "number" part to the variable name. 19:04:35 did you have the : before the get-number? 19:04:36 Was I wrong on that assumption? 19:04:57 yes 19:05:27 s>number is a word in gforth that converts a string into a number 19:06:24 I hadn't placed but I added it now. 19:06:37 Guest23783: You find, in general, in Forth that you need to explicitly do things that are done "automagically for you" in many other languages. 19:07:00 I see, could I combine it with a "!" to do an assignment. 19:07:04 Like in other languages you "tell the compiler" that you want string-to-number conversion simply by asking to input a variable that is of a number type. 19:07:08 The compiler puts it all together for you. 19:07:16 In for you tack it all together yourself. 19:07:23 get-number n1 ! 19:07:24 KipIngram: True man, but that is very interesting, may I say. 19:08:04 I think so too. You could consider having to do that stuff "manually" a burden, I guess, but on the other hand it gives you full control over everything that happens. 19:08:38 There's a kind of satisfaction in knowing that a word does exactly the same thing every time. 19:09:58 : getn pad 80 accept >r 0. pad r> >number 2drop drop ; 19:10:20 this one should work on any ANS compliant Forth 19:15:36 KipIngram: No burden at all, it is freedom. 19:18:31 crc: That will convert what is in the stack or the input? 19:19:09 this reads input from the keyboard and returns a number 19:19:21 returns the number on the stack. 19:20:36 And how would I take that value? 19:21:43 the number is left on the stack. You could use ! to store it in a variable, or just pass it to another word 19:23:56 I guess I could use a "pop" in here.? 19:24:35 what do you mean by "pop" ? 19:29:25 To take that stack value and reference it with a keyword, like a variable. 19:30:05 You mean "store it"? 19:30:10 In the variable? 19:30:22 Exactly. 19:30:43 --- quit: pierpa (Quit: Page closed) 19:31:08 ! is the Forth word that does that. You've got that number on the stack, you say
! 19:31:17 Afterward both the number and the address are gone. 19:31:46
can come about in any way - you can type in a literal numeric address, you can execute a word defined by VARIABLE, do some calculation, or whatever. 19:31:58 Where it came from doesn't matter. 19:41:42 --- quit: X-Scale (Ping timeout: 252 seconds) 19:46:14 I tried this: https://privatebin.net/?2184b73d8de56186#j5L7BDaRrO9hRfLf2LfoLDCLMIbSfVr4sEAy3qywvF0= 19:46:45 It didn't gave an error. But it didn't read the input either. 19:46:54 That was the result: https://privatebin.net/?e7e934a8103c7630#fzyF8bw6NzjoMCWsSc3QQYHh6kpxj6nZVR+kNADhQ90= 19:48:18 Do I need to make it wait? 19:48:25 https://privatebin.net/?b9ebe10e9f5eb204#65reu+69wl2TK2BzVDzU25ccSOs66JaFrS7gJ4QeM8o= 19:51:38 `getn` is a word thatmcanmbe reused. When called it'll read input into `pad` (a standard Forth buffer), convert the input to a number, and leave it on the stack 19:52:21 so `getn n1 !` to read a number and store it into `n1` 19:53:31 `pad n1 !` stores the address of `pad` in `n1`, which isn't what you want for this 19:53:37 I see. 19:53:50 That definition looks similar to a macro. 19:55:37 A macro would behave as though you had the content literally "inserted" everywhere you use it. 19:55:44 The : before and ; after make it a "definition." 19:55:58 The system makes a list of addresses that tell it where to find the words inside the definition. 19:56:17 Then when you use the word it "steps through" that list of definitions, executing each component word in turn. 19:56:29 So it's more like "deffing" a function in Python. 19:57:56 I can understand it now. 19:58:09 Thanks guys. That stuff is amazing. 19:58:28 :-) 19:58:55 --- quit: dddddd (Read error: Connection reset by peer) 20:00:20 --- join: X-Scale (~ARM@83.223.242.128) joined #forth 20:01:33 See ya. Take care. ^^ 20:02:18 --- part: Guest23783 left #forth 20:15:10 --- quit: pierpal (Quit: Poof) 20:15:28 --- join: pierpal (~pierpal@host60-229-dynamic.16-87-r.retail.telecomitalia.it) joined #forth 20:45:07 --- join: dave9 (~dave@90.20.215.218.dyn.iprimus.net.au) joined #forth 22:01:57 --- quit: dave9 (Quit: one love) 23:27:22 --- join: dave9 (~dave@90.20.215.218.dyn.iprimus.net.au) joined #forth 23:59:59 --- log: ended forth/18.09.05