Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #25794 > unrolled thread
| Started by | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| First post | 2013-09-18 22:55 -0700 |
| Last post | 2013-09-24 07:46 -0700 |
| Articles | 20 on this page of 35 — 15 participants |
Back to article view | Back to comp.lang.forth
well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-18 22:55 -0700
Re: well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-18 22:58 -0700
Re: well this code works and I had some guy say it doesn't VoidVolker <voidvolker@gmail.com> - 2013-09-18 23:35 -0700
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-19 03:09 -0400
Re: well this code works and I had some guy say it doesn't gavino_himself <visploveslisp@gmail.com> - 2013-09-19 01:11 -0700
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-19 04:32 -0400
Re: well this code works and I had some guy say it doesn't Elizabeth D Rather <erather@forth.com> - 2013-09-19 14:15 -1000
Re: well this code works and I had some guy say it doesn't "Ed" <invalid@invalid.com> - 2013-09-21 12:48 +1000
Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-20 17:52 -1000
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 08:46 -0400
Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 10:40 -0400
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 10:48 -0400
Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 18:12 -0400
Re: well this code works and I had some guy say it doesn't albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-09-23 16:59 +0000
Re: well this code works and I had some guy say it doesn't "WJ" <w_a_x_man@yahoo.com> - 2013-09-21 17:48 +0000
Re: well this code works and I had some guy say it doesn't Doug Hoffman <glidedog@gmail.com> - 2013-09-21 19:34 -0400
Re: well this code works and I had some guy say it doesn't "Ed" <invalid@invalid.com> - 2013-09-22 11:51 +1000
Re: well this code works and I had some guy say it doesn't hughaguilar96@yahoo.com - 2013-09-21 21:09 -0700
Re: well this code works and I had some guy say it doesn't "Rod Pemberton" <dont_use_email@nohavenotit.com> - 2013-09-21 13:09 -0400
Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-21 08:37 -1000
Re: well this code works and I had some guy say it doesn't albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-09-23 17:26 +0000
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-21 02:19 -0700
Re: well this code works and I had some guy say it doesn't "WJ" <w_a_x_man@yahoo.com> - 2013-09-19 09:16 +0000
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:08 -0700
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-21 08:47 -0400
Re: well this code works and I had some guy say it doesn't Spam@ControlQ.com - 2013-09-19 11:16 -0400
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:07 -0700
Re: well this code works and I had some guy say it doesn't "Rod Pemberton" <dont_use_email@nohavenotit.com> - 2013-09-20 04:37 -0400
Re: well this code works and I had some guy say it doesn't "Elizabeth D. Rather" <erather@forth.com> - 2013-09-19 22:45 -1000
Re: well this code works and I had some guy say it doesn't Howerd <howerdo@yahoo.co.uk> - 2013-09-20 01:49 -0700
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:10 -0700
Re: well this code works and I had some guy say it doesn't rickman <gnuarm@gmail.com> - 2013-09-20 08:19 -0400
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:11 -0700
Re: well this code works and I had some guy say it doesn't the_gavino_himself <visphatesjava@gmail.com> - 2013-09-20 23:09 -0700
Re: well this code works and I had some guy say it doesn't Mark Wills <markrobertwills@yahoo.co.uk> - 2013-09-24 07:46 -0700
Page 1 of 2 [1] 2 Next page →
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-09-18 22:55 -0700 |
| Subject | well this code works and I had some guy say it doesn't |
| Message-ID | <d7f43d90-5ea4-47f4-b309-de6fbad1f677@googlegroups.com> |
$ gforth Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc. Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' Type `bye' to exit : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain ok 34 55 stock-gain 61 precent ok IN YOUR FUCKING FACE!!
[toc] | [next] | [standalone]
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-09-18 22:58 -0700 |
| Message-ID | <17d157f0-ec01-4076-800a-cd2d9ae515a1@googlegroups.com> |
| In reply to | #25794 |
I get now more than ever that its not me whos dumb... Its others... I am right on the fukin money....and know exactly whats up. Many shitheads wheedle through life and conversations with major sloppiness. I mean telling me my code doesn't work without even typing it in WHAT THE FUCK???
[toc] | [prev] | [next] | [standalone]
| From | VoidVolker <voidvolker@gmail.com> |
|---|---|
| Date | 2013-09-18 23:35 -0700 |
| Message-ID | <5e19d09b-027f-420a-a569-5123a16319e6@googlegroups.com> |
| In reply to | #25794 |
четверг, 19 сентября 2013 г., 9:55:55 UTC+4 пользователь gavino_himself написал:
> $ gforth
> Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc.
> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
> Type `bye' to exit
>
> : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain ok
> 34 55 stock-gain
> 61 precent
> ok
>
>
> IN YOUR FUCKING FACE!!
Yes, the code is work, but it's calculate not percents =) Look here:
30 100 stock-gain
233 precent
100 30 stock-gain .
-70 precent
Now, let's calculate real percents - the word */ exist for it:
: p% 100 SWAP */ CR . ." %" CR ; ok
34 55 p%
61 %
ok
Or:
: p%2 10000 SWAP */ CR S>D <# [CHAR] % HOLD # # [CHAR] . HOLD #S #> TYPE CR ;
34 55 p%2
61.81%
ok
30 100 p%2
30.00%
ok
100 30 p%2
333.33%
ok
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2013-09-19 03:09 -0400 |
| Message-ID | <l1e7vl$6db$1@dont-email.me> |
| In reply to | #25796 |
On 9/19/2013 2:35 AM, VoidVolker wrote: > четверг, 19 сентября 2013 г., 9:55:55 UTC+4 пользователь gavino_himself написал: >> $ gforth >> Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc. >> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' >> Type `bye' to exit >> >> : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain ok >> 34 55 stock-gain >> 61 precent >> ok >> >> >> IN YOUR FUCKING FACE!! > > Yes, the code is work, but it's calculate not percents =) Look here: > > 30 100 stock-gain > 233 precent > > 100 30 stock-gain . > -70 precent > > Now, let's calculate real percents - the word */ exist for it: > : p% 100 SWAP */ CR . ." %" CR ; ok > 34 55 p% > 61 % > ok > > Or: > > : p%2 10000 SWAP */ CR S>D<# [CHAR] % HOLD # # [CHAR] . HOLD #S #> TYPE CR ; > 34 55 p%2 > 61.81% > ok > > 30 100 p%2 > 30.00% > ok > > 100 30 p%2 > 333.33% > ok I think you don't understand what Gavino's code is doing. It is calculating the percent gain or loss, not the simple percent ratio. To get gain you take the ratio, subtract one, then multiply by 100. / 1.0 - 100.0 * (floating point numbers, not literal forth) That is why he subtracts 100, the same as subtracting the 1, but after multiplying by 100. -- Rick
[toc] | [prev] | [next] | [standalone]
| From | gavino_himself <visploveslisp@gmail.com> |
|---|---|
| Date | 2013-09-19 01:11 -0700 |
| Message-ID | <e4e5f501-9e08-41a7-b826-6998dcb14e86@googlegroups.com> |
| In reply to | #25798 |
On Thursday, September 19, 2013 12:09:31 AM UTC-7, rickman wrote: > On 9/19/2013 2:35 AM, VoidVolker wrote: > > > четверг, 19 сентября 2013 г., 9:55:55 UTC+4 пользователь gavino_himself написал: > > >> $ gforth > > >> Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc. > > >> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' > > >> Type `bye' to exit > > >> > > >> : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain ok > > >> 34 55 stock-gain > > >> 61 precent > > >> ok > > >> > > >> > > >> IN YOUR FUCKING FACE!! > > > > > > Yes, the code is work, but it's calculate not percents =) Look here: > > > > > > 30 100 stock-gain > > > 233 precent > > > > > > 100 30 stock-gain . > > > -70 precent > > > > > > Now, let's calculate real percents - the word */ exist for it: > > > : p% 100 SWAP */ CR . ." %" CR ; ok > > > 34 55 p% > > > 61 % > > > ok > > > > > > Or: > > > > > > : p%2 10000 SWAP */ CR S>D<# [CHAR] % HOLD # # [CHAR] . HOLD #S #> TYPE CR ; > > > 34 55 p%2 > > > 61.81% > > > ok > > > > > > 30 100 p%2 > > > 30.00% > > > ok > > > > > > 100 30 p%2 > > > 333.33% > > > ok > > > > I think you don't understand what Gavino's code is doing. It is > > calculating the percent gain or loss, not the simple percent ratio. To > > get gain you take the ratio, subtract one, then multiply by 100. > > > > / 1.0 - 100.0 * (floating point numbers, not literal forth) > > > > That is why he subtracts 100, the same as subtracting the 1, but after > > multiplying by 100. > > > > -- > > > > Rick thank you rickman I think my code is nice. How should it be commented? I haven't got the knack yet....
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2013-09-19 04:32 -0400 |
| Message-ID | <l1ecs4$t1m$1@dont-email.me> |
| In reply to | #25801 |
On 9/19/2013 4:11 AM, gavino_himself wrote: > On Thursday, September 19, 2013 12:09:31 AM UTC-7, rickman wrote: >> On 9/19/2013 2:35 AM, VoidVolker wrote: >> >>> четверг, 19 сентября 2013 г., 9:55:55 UTC+4 пользователь gavino_himself написал: >> >>>> $ gforth >> >>>> Gforth 0.7.2, Copyright (C) 1995-2008 Free Software Foundation, Inc. >> >>>> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license' >> >>>> Type `bye' to exit >> >>>> >> >>>> : stock-gain 100 * swap / 100 - cr . ." precent" cr ; redefined stock-gain ok >> >>>> 34 55 stock-gain >> >>>> 61 precent >> >>>> ok >> >>>> >> >>>> >> >>>> IN YOUR FUCKING FACE!! >> >>> >> >>> Yes, the code is work, but it's calculate not percents =) Look here: >> >>> >> >>> 30 100 stock-gain >> >>> 233 precent >> >>> >> >>> 100 30 stock-gain . >> >>> -70 precent >> >>> >> >>> Now, let's calculate real percents - the word */ exist for it: >> >>> : p% 100 SWAP */ CR . ." %" CR ; ok >> >>> 34 55 p% >> >>> 61 % >> >>> ok >> >>> >> >>> Or: >> >>> >> >>> : p%2 10000 SWAP */ CR S>D<# [CHAR] % HOLD # # [CHAR] . HOLD #S #> TYPE CR ; >> >>> 34 55 p%2 >> >>> 61.81% >> >>> ok >> >>> >> >>> 30 100 p%2 >> >>> 30.00% >> >>> ok >> >>> >> >>> 100 30 p%2 >> >>> 333.33% >> >>> ok >> >> >> >> I think you don't understand what Gavino's code is doing. It is >> >> calculating the percent gain or loss, not the simple percent ratio. To >> >> get gain you take the ratio, subtract one, then multiply by 100. >> >> >> >> / 1.0 - 100.0 * (floating point numbers, not literal forth) >> >> >> >> That is why he subtracts 100, the same as subtracting the 1, but after >> >> multiplying by 100. >> >> >> >> -- >> >> >> >> Rick > > thank you rickman > > I think my code is nice. > > How should it be commented? > > I haven't got the knack yet.... I don't know, but I would find it more clear to write : stock-gain over - 100 rot */ cr . ." percent" cr ; Certainly there could be a stack comment ( starting_value final_value -- %change ) -- Rick
[toc] | [prev] | [next] | [standalone]
| From | Elizabeth D Rather <erather@forth.com> |
|---|---|
| Date | 2013-09-19 14:15 -1000 |
| Message-ID | <eOKdnYSqdZ0yDqbPnZ2dnUVZ_g2dnZ2d@supernews.com> |
| In reply to | #25802 |
On 9/18/2013 10:32 PM, rickman wrote: > On 9/19/2013 4:11 AM, gavino_himself wrote: ... >> I think my code is nice. >> >> How should it be commented? >> >> I haven't got the knack yet.... > > I don't know, but I would find it more clear to write > > : stock-gain over - 100 rot */ cr . ." percent" cr ; > > Certainly there could be a stack comment > > ( starting_value final_value -- %change ) \ Returns change in value given the starting and final value. : stock-gain ( ns nf -- n% ) over - 100 rot */ cr . ." percent" cr ; Never, never, never write a definition without a stack comment. The stack notation reflects the number type as well as meaning. Using */ is advantageous because it is both faster and can give a more accurate answer, since it multiplies giving a double-length product befroe performing the divide. Using * alone in this case can cause loss of precision due to overflow, if the numbers are large. And, gavino, if you want to be liked here, you should avoid talking dirty. Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | "Ed" <invalid@invalid.com> |
|---|---|
| Date | 2013-09-21 12:48 +1000 |
| Message-ID | <l1j18c$ob9$1@speranza.aioe.org> |
| In reply to | #25825 |
Elizabeth D Rather wrote: > ... > Never, never, never write a definition without a stack comment. > ... Funny because that's *exactly* how some Forth Wizards write their code. Maintenance by others aside, *how* they manage to work that way without getting lost is difficult to comprehend. Who am I talking about? Well, there is Chuck Moore (source for Colorforth is uncommented) and Stackworks author Mike Brothers wherein the entire system source there is not a single stack comment.
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-09-20 17:52 -1000 |
| Message-ID | <YrOdncSUTPKMhaDPnZ2dnUVZ_oOdnZ2d@supernews.com> |
| In reply to | #25866 |
On 9/20/13 4:48 PM, Ed wrote: > Elizabeth D Rather wrote: >> ... >> Never, never, never write a definition without a stack comment. >> ... > > Funny because that's *exactly* how some Forth Wizards write their code. > Maintenance by others aside, *how* they manage to work that way without > getting lost is difficult to comprehend. > > Who am I talking about? Well, there is Chuck Moore (source for Colorforth > is uncommented) and Stackworks author Mike Brothers wherein the entire > system source there is not a single stack comment. That's sad. Chuck basically invented stack comments, and insisted on their use when he was doing applications. FORTH, Inc. requires them, and the best programmers I've worked with for many years (alas, I haven't worked with Chuck since 1982) always include stack comments. For learners, stack comments are especially helpful, since by having to state them at the beginning of the definition they're led to focus on the stack going in and coming out, and the comment is there to remind them. One of the early simple exercises in Forth Application Techniques involves printing out [n] stars, which many define as: : STARS ( n -- ) 0 DO ." * " LOOP DROP ; The ones who include the stack comment are far less likely to just type STARS without an argument or forget the DROP at the end. But the consequences of forgetting the number are also a good teaching moment. ;-) Cheers, Elizabeth -- ================================================== Elizabeth D. Rather (US & Canada) 800-55-FORTH FORTH Inc. +1 310.999.6784 5959 West Century Blvd. Suite 700 Los Angeles, CA 90045 http://www.forth.com "Forth-based products and Services for real-time applications since 1973." ==================================================
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2013-09-21 08:46 -0400 |
| Message-ID | <l1k4fp$hqi$1@dont-email.me> |
| In reply to | #25868 |
On 9/20/2013 11:52 PM, Elizabeth D. Rather wrote: > On 9/20/13 4:48 PM, Ed wrote: >> Elizabeth D Rather wrote: >>> ... >>> Never, never, never write a definition without a stack comment. >>> ... >> >> Funny because that's *exactly* how some Forth Wizards write their code. >> Maintenance by others aside, *how* they manage to work that way without >> getting lost is difficult to comprehend. >> >> Who am I talking about? Well, there is Chuck Moore (source for Colorforth >> is uncommented) and Stackworks author Mike Brothers wherein the entire >> system source there is not a single stack comment. > > That's sad. Chuck basically invented stack comments, and insisted on > their use when he was doing applications. FORTH, Inc. requires them, and > the best programmers I've worked with for many years (alas, I haven't > worked with Chuck since 1982) always include stack comments. > > For learners, stack comments are especially helpful, since by having to > state them at the beginning of the definition they're led to focus on > the stack going in and coming out, and the comment is there to remind > them. One of the early simple exercises in Forth Application Techniques > involves printing out [n] stars, which many define as: > > : STARS ( n -- ) 0 DO ." * " LOOP DROP ; > > The ones who include the stack comment are far less likely to just type > STARS without an argument or forget the DROP at the end. But the > consequences of forgetting the number are also a good teaching moment. ;-) I don't think you are helping your argument. The DROP at the end of your definition is incorrect. The input argument is consumed by the DO. In WIN32FORTH... : STARS ( n -- ) 0 DO ." * " LOOP DROP ; ok 3 stars * * * ^^^^^ Error(-4): STARS stack underflow : STARS ( n -- ) 0 DO ." * " LOOP ; ^^^^^ Warning(-4100): STARS is redefined ok 3 stars * * * ok -- Rick
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2013-09-21 10:40 -0400 |
| Message-ID | <523daff7$0$304$14726298@news.sunsite.dk> |
| In reply to | #25884 |
On 9/21/13 8:46 AM, rickman wrote: > I don't think you are helping your argument. The DROP at the end of > your definition is incorrect. If you've never made an obvious typo then you're a better man than me. Or perhaps the example was from a "teachable moment" exercise showing the problem caused by stack comment mismatch. Regardless "Never write a definition without a stack comment" is fundamental, and solid advice. -Doug
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2013-09-21 10:48 -0400 |
| Message-ID | <l1kbjr$nvh$1@dont-email.me> |
| In reply to | #25889 |
On 9/21/2013 10:40 AM, Doug Hoffman wrote: > On 9/21/13 8:46 AM, rickman wrote: > >> I don't think you are helping your argument. The DROP at the end of >> your definition is incorrect. > > If you've never made an obvious typo then you're a better man than me. > Or perhaps the example was from a "teachable moment" exercise showing > the problem caused by stack comment mismatch. > > Regardless "Never write a definition without a stack comment" is > fundamental, and solid advice. Just the opposite, I can't remember *ever* writing a program that ran the first time regardless of how small it was. But that is irrelevant. The point is that this was supposed to be an example of how stack comments help you avoid exactly the error made. "The ones who include the stack comment are far less likely to just type STARS without an argument or forget the DROP at the end." It was stated that the comment would help you *remember* to use the DROP when the opposite was needed. Yes, this is just a simple typo, or more like a brain cramp in my opinion. But the fact remains that the example given shows that the comment did not work at all in this case. I'm not taking any sides in the argument of pro/con stack comments. I'm just sayin'... -- Rick
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2013-09-21 18:12 -0400 |
| Message-ID | <523e19d9$0$298$14726298@news.sunsite.dk> |
| In reply to | #25891 |
On 9/21/13 10:48 AM, rickman wrote: > I'm not taking any sides in the argument of pro/con stack comments. I strongly suggest you take the side of pro if you want anyone else to read your code. If you've figured out how to write Forth programs without stack comments then I am amazed and wish you continued success. -Doug
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2013-09-23 16:59 +0000 |
| Message-ID | <52407363$0$26883$e4fe514c@dreader37.news.xs4all.nl> |
| In reply to | #25891 |
In article <l1kbjr$nvh$1@dont-email.me>, rickman <gnuarm@gmail.com> wrote: >On 9/21/2013 10:40 AM, Doug Hoffman wrote: >> On 9/21/13 8:46 AM, rickman wrote: >> >>> I don't think you are helping your argument. The DROP at the end of >>> your definition is incorrect. >> >> If you've never made an obvious typo then you're a better man than me. >> Or perhaps the example was from a "teachable moment" exercise showing >> the problem caused by stack comment mismatch. >> >> Regardless "Never write a definition without a stack comment" is >> fundamental, and solid advice. > >Just the opposite, I can't remember *ever* writing a program that ran >the first time regardless of how small it was. But that is irrelevant. > The point is that this was supposed to be an example of how stack >comments help you avoid exactly the error made. I remember I managed once and it was proudly published in c.l.f. The program was meticulously documented with a technique superior to the usual Forth stack comment. Without some such it is impossible for a Forth or assembler program to run the first time. There may be exceptional "real" programmers who stand a chance. The results are programs that are no good to be used in production and are summarily rejected by safety boards. > >"The ones who include the stack comment are far less likely to just type >STARS without an argument or forget the DROP at the end." > >It was stated that the comment would help you *remember* to use the DROP >when the opposite was needed. > >Yes, this is just a simple typo, or more like a brain cramp in my >opinion. But the fact remains that the example given shows that the >comment did not work at all in this case. > >I'm not taking any sides in the argument of pro/con stack comments. I'm >just sayin'... I can image a tool that says "misleading stack comment" or "unbalanced stack in definition". I had this editor stack coloring that would help notice problems. > >-- > >Rick Groetjes Albert -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2013-09-21 17:48 +0000 |
| Message-ID | <l1km61$ltd$1@dont-email.me> |
| In reply to | #25889 |
Doug Hoffman wrote: > If you've never made an obvious typo then you're a better man than me Correction: "a better man than I" or "a better man than I am"
[toc] | [prev] | [next] | [standalone]
| From | Doug Hoffman <glidedog@gmail.com> |
|---|---|
| Date | 2013-09-21 19:34 -0400 |
| Message-ID | <523e2cfc$0$297$14726298@news.sunsite.dk> |
| In reply to | #25896 |
On 9/21/13 1:48 PM, WJ wrote: > Doug Hoffman wrote: > >> If you've never made an obvious typo then you're a better man than me > > Correction: > > "a better man than I" > or > "a better man than I am" The word "than" performs the task of a preposition (the way that like does. "He is a Forth programmer like me") and so should be followed by the objective form of the pronoun. Hence "You are a better man than me." is a correct form. Using " ... better man than I am" is also correct, but is typically used in more formal writing. -Doug
[toc] | [prev] | [next] | [standalone]
| From | "Ed" <invalid@invalid.com> |
|---|---|
| Date | 2013-09-22 11:51 +1000 |
| Message-ID | <l1li8f$244$1@speranza.aioe.org> |
| In reply to | #25889 |
Doug Hoffman wrote: > On 9/21/13 8:46 AM, rickman wrote: > > > I don't think you are helping your argument. The DROP at the end of > > your definition is incorrect. > > If you've never made an obvious typo then you're a better man than me. > Or perhaps the example was from a "teachable moment" exercise showing > the problem caused by stack comment mismatch. > > Regardless "Never write a definition without a stack comment" is > fundamental, and solid advice. I agree. Nevertheless it is a curious - and I would say intriguing - fact that there are programmers who are so adept at what they do, that they begin to perform what others in their field see as 'impossible'. "Keep your eyes on the road" is what every learner-driver is told. Yet experienced drivers barely need to.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@yahoo.com |
|---|---|
| Date | 2013-09-21 21:09 -0700 |
| Message-ID | <1c2c813c-8d86-4c94-aaa1-345f1dea71dd@googlegroups.com> |
| In reply to | #25916 |
On Saturday, September 21, 2013 6:51:25 PM UTC-7, Ed wrote: > Doug Hoffman wrote: > > On 9/21/13 8:46 AM, rickman wrote: > > > I don't think you are helping your argument. The DROP at the end of > > > your definition is incorrect. > > > If you've never made an obvious typo then you're a better man than me. > > Or perhaps the example was from a "teachable moment" exercise showing > > the problem caused by stack comment mismatch. > > Regardless "Never write a definition without a stack comment" is > > fundamental, and solid advice. > > I agree. > > Nevertheless it is a curious - and I would say intriguing - fact that there are > programmers who are so adept at what they do, that they begin to perform > what others in their field see as 'impossible'. > > "Keep your eyes on the road" is what every learner-driver is told. Yet > experienced drivers barely need to. Any Forth programmer who fails to provide a stack-picture comment for every colon word is purposely obfuscating his code. Here is an example: https://groups.google.com/forum/#!topic/comp.lang.forth/3Y4w_MdYl0k Most of the time, the programmer actually had stack-picture comments when he wrote the code, but after the code was written and tested he removed the comments to obfuscate his code --- I'm pretty sure that was what Alex Wegel was doing, in an effort to baffle everybody with his supposed brilliance. As for Elizabeth Rather's STAR word, that mistake occurred in an unusual way. E.R. isn't actually a Forth programmer --- she just teaches Forth using "Starting Forth" as her textbook. STAR is one of the examples from that book, and she apparently tried to reproduce it from memory without the book in front of her, and got it wrong. This is an unusual problem, because programmers don't generally regurgitate examples from books, but more typically write original code --- a completely different mental process. Most likely, all of WJ's Ruby examples are coming from some textbook, but he is another strange case. As for driving, of course you have to keep your eyes on the road --- try closing your eyes and count how many seconds it takes before you crash! The difference between novice and experienced drivers, is that the novices do this consciously, whereas the experienced let their subconscious do the job while the conscious thinks about other things --- in either case though, the eyes have to be on the road to provide the brain with the needed information, or you crash. The subconscious is only capable of doing fairly simple jobs, and programming isn't one of them. There has been a lot of effort to make programming so easy that it can be done without any thinking required, such as by pointing-and-clicking to paste together code snippets as done in Visual Basic --- but it is arguable that this isn't really programming at all.
[toc] | [prev] | [next] | [standalone]
| From | "Rod Pemberton" <dont_use_email@nohavenotit.com> |
|---|---|
| Date | 2013-09-21 13:09 -0400 |
| Message-ID | <op.w3rtxxu40e5s1z@localhost> |
| In reply to | #25884 |
On Sat, 21 Sep 2013 08:46:46 -0400, rickman <gnuarm@gmail.com> wrote: > On 9/20/2013 11:52 PM, Elizabeth D. Rather wrote: >> On 9/20/13 4:48 PM, Ed wrote: >>> Elizabeth D Rather wrote: ... >> For learners, stack comments are especially helpful, since by having to >> state them at the beginning of the definition they're led to focus on >> the stack going in and coming out, and the comment is there to remind >> them. One of the early simple exercises in Forth Application Techniques >> involves printing out [n] stars, which many define as: >> >> : STARS ( n -- ) 0 DO ." * " LOOP DROP ; >> >> The ones who include the stack comment are far less likely to just type >> STARS without an argument or forget the DROP at the end. But the >> consequences of forgetting the number are also a good teaching moment. >> ;-) > > I don't think you are helping your argument. The DROP at the end of > your definition is incorrect. The input argument is consumed by the DO. Wow, the troll discusses Forth, gets one correct, and isn't calling someone else a troll. What's even more notable is that she (IIRC) pointed out to me, and either Andrew or Mark, maybe about a year and half ago, that if our loop control words were coded correctly then they shouldn't need DROPs or 2DROPs at the end. Yet, she used a DROP after a loop. Rod Pemberton
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2013-09-21 08:37 -1000 |
| Message-ID | <KOOdnQTUasnHeqDPnZ2dnUVZ_rKdnZ2d@supernews.com> |
| In reply to | #25894 |
On 9/21/13 7:09 AM, Rod Pemberton wrote:
> On Sat, 21 Sep 2013 08:46:46 -0400, rickman <gnuarm@gmail.com> wrote:
>
>> On 9/20/2013 11:52 PM, Elizabeth D. Rather wrote:
>>> On 9/20/13 4:48 PM, Ed wrote:
>>>> Elizabeth D Rather wrote:
> ...
>
>>> For learners, stack comments are especially helpful, since by having to
>>> state them at the beginning of the definition they're led to focus on
>>> the stack going in and coming out, and the comment is there to remind
>>> them. One of the early simple exercises in Forth Application Techniques
>>> involves printing out [n] stars, which many define as:
>>>
>>> : STARS ( n -- ) 0 DO ." * " LOOP DROP ;
>>>
>>> The ones who include the stack comment are far less likely to just type
>>> STARS without an argument or forget the DROP at the end. But the
>>> consequences of forgetting the number are also a good teaching
>>> moment. ;-)
>>
>> I don't think you are helping your argument. The DROP at the end of
>> your definition is incorrect. The input argument is consumed by the DO.
>
> Wow, the troll discusses Forth, gets one correct, and isn't calling
> someone else a troll.
>
> What's even more notable is that she (IIRC) pointed out to me, and
> either Andrew or Mark, maybe about a year and half ago, that if our
> loop control words were coded correctly then they shouldn't need
> DROPs or 2DROPs at the end. Yet, she used a DROP after a loop.
LOL, that's what I get for posting late at night after too much wine,
*not* recommended programming practice! But another point under
discussion is certainly illustrated here, the one about interactive
testing, in which the error would have been immediately apparent!
But in fact, having a DROP or 2DROP at the end of a loop is quite
common, and for very good reasons. The very next problem in this
sequence is BOX:
: BOX ( nr nc -- ) \ Make a star box of nr rows and nc columns
CR SWAP 0 DO DUP STARS CR LOOP DROP ;
It was that DROP that was stuck in my mind. This is actually a very
common scenario. We can also discuss that SWAP: the arguments are the
way they are because it is often more natural in the calling code to
order arguments for this kind of scenario with the faster-changing
element on top. Putting the SWAP in here *might* save a bunch of SWAPs
in the calling code (if not, of course, you change the order). Context
is important. The difficulty with sample problems is that you can't
always see the context, but in a class we can discuss the options.
Cheers,
Elizabeth
--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
==================================================
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.forth
csiph-web