Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #42497 > unrolled thread
| Started by | Chris Curl <ccurl609@gmail.com> |
|---|---|
| First post | 2015-10-09 06:30 -0700 |
| Last post | 2015-10-10 22:53 -0700 |
| Articles | 16 — 9 participants |
Back to article view | Back to comp.lang.forth
Newbie alert: what is the ANS word for clearing the stack without aborting? Chris Curl <ccurl609@gmail.com> - 2015-10-09 06:30 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? "WJ" <w_a_x_man@yahoo.com> - 2015-10-09 13:46 +0000
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Coos Haak <chforth@hccnet.nl> - 2015-10-09 17:35 +0200
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Mark Wills <markwills1970@gmail.com> - 2015-10-09 07:08 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Coos Haak <chforth@hccnet.nl> - 2015-10-09 17:38 +0200
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Ching-Tang Tseng <ilikeforth@gmail.com> - 2015-10-09 08:10 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Coos Haak <chforth@hccnet.nl> - 2015-10-09 17:42 +0200
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Chris Curl <ccurl609@gmail.com> - 2015-10-09 08:57 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Ching-Tang Tseng <ilikeforth@gmail.com> - 2015-10-09 08:59 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-09 16:00 +0000
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? "Elizabeth D. Rather" <erather@forth.com> - 2015-10-09 08:38 -1000
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Chris Curl <ccurl609@gmail.com> - 2015-10-09 12:31 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? "Elizabeth D. Rather" <erather@forth.com> - 2015-10-09 10:29 -1000
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? "HAA" <someone@microsoft.com> - 2015-10-11 11:51 +1000
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? Ching-Tang Tseng <ilikeforth@gmail.com> - 2015-10-10 18:28 -0700
Re: Newbie alert: what is the ANS word for clearing the stack without aborting? hughaguilar96@gmail.com - 2015-10-10 22:53 -0700
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2015-10-09 06:30 -0700 |
| Subject | Newbie alert: what is the ANS word for clearing the stack without aborting? |
| Message-ID | <549578e4-aa40-4ea4-b3f2-568a39bb4a7a@googlegroups.com> |
I have seen a 0SP word bandied about, which is easy enough to implement.
: 0SP DEPTH ?DUP IF 0 DO DROP LOOP THEN ;
But I didn't see a word in the standard for it though.
If there is no word in the standard for it, what word do you folks use?
Even though I seriously doubt my implementation will 100% ANS compliant, I figure I might as well use word names that most folks use for stuff most people want to do.
[toc] | [next] | [standalone]
| From | "WJ" <w_a_x_man@yahoo.com> |
|---|---|
| Date | 2015-10-09 13:46 +0000 |
| Message-ID | <mv8gfl$lbs$1@dont-email.me> |
| In reply to | #42497 |
Chris Curl wrote: > I have seen a 0SP word bandied about, which is easy enough to implement. > > : 0SP DEPTH ?DUP IF 0 DO DROP LOOP THEN ; The standard Forth word to clear the stack is "clr". Oforth: >2 3 4 .s [1] (Integer) 4 [2] (Integer) 3 [3] (Integer) 2 ok >clr .s Empty
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-10-09 17:35 +0200 |
| Message-ID | <154kbardxapy7$.13ux7l6v5w5th.dlg@40tude.net> |
| In reply to | #42498 |
Op Fri, 9 Oct 2015 13:46:29 +0000 (UTC) schreef WJ: > Chris Curl wrote: > >> I have seen a 0SP word bandied about, which is easy enough to implement. >> >> : 0SP DEPTH ?DUP IF 0 DO DROP LOOP THEN ; > > The standard Forth word to clear the stack is "clr". Which standard? groet Coos
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-10-09 07:08 -0700 |
| Message-ID | <2676ecfd-a075-4bf3-8b93-4a639f49f3a7@googlegroups.com> |
| In reply to | #42497 |
On Friday, 9 October 2015 14:30:47 UTC+1, Chris Curl wrote: > I have seen a 0SP word bandied about, which is easy enough to implement. > > : 0SP DEPTH ?DUP IF 0 DO DROP LOOP THEN ; > > But I didn't see a word in the standard for it though. > > If there is no word in the standard for it, what word do you folks use? > > Even though I seriously doubt my implementation will 100% ANS compliant, I figure I might as well use word names that most folks use for stuff most people want to do. : clr ( ... -- ) s0 sp! ;
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-10-09 17:38 +0200 |
| Message-ID | <18tkmoyj815d3.15o8ccjt0w1xg$.dlg@40tude.net> |
| In reply to | #42501 |
Op Fri, 9 Oct 2015 07:08:40 -0700 (PDT) schreef Mark Wills: > On Friday, 9 October 2015 14:30:47 UTC+1, Chris Curl wrote: >> I have seen a 0SP word bandied about, which is easy enough to implement. >> >> : 0SP DEPTH ?DUP IF 0 DO DROP LOOP THEN ; >> >> But I didn't see a word in the standard for it though. >> >> If there is no word in the standard for it, what word do you folks use? >> >> Even though I seriously doubt my implementation will 100% ANS compliant, I figure I might as well use word names that most folks use for stuff most people want to do. > >: clr ( ... -- ) s0 sp! ; : clr dsp0 dsp! ; I may write this, because s0 sp! dsp0 dsp! are never declared in the standard ;-) : clr begin depth while drop repeat ; Slow version that uses only standard words groet Coos
[toc] | [prev] | [next] | [standalone]
| From | Ching-Tang Tseng <ilikeforth@gmail.com> |
|---|---|
| Date | 2015-10-09 08:10 -0700 |
| Message-ID | <1cff2526-4f45-4b66-b353-408f8c8aaecc@googlegroups.com> |
| In reply to | #42497 |
'''''''' Enter
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-10-09 17:42 +0200 |
| Message-ID | <mr9e0fdxz2sb$.1b9qbphbt0g5r.dlg@40tude.net> |
| In reply to | #42504 |
Op Fri, 9 Oct 2015 08:10:40 -0700 (PDT) schreef Ching-Tang Tseng: > ''''''' It clears the stack already, but leaves an error message on the screen and aborts. So you can not use this in the middle of source text. groet Coos
[toc] | [prev] | [next] | [standalone]
| From | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2015-10-09 08:57 -0700 |
| Message-ID | <63a04867-832d-4601-8202-d60ef2e05c02@googlegroups.com> |
| In reply to | #42497 |
Thanks folks. CLR it is.
[toc] | [prev] | [next] | [standalone]
| From | Ching-Tang Tseng <ilikeforth@gmail.com> |
|---|---|
| Date | 2015-10-09 08:59 -0700 |
| Message-ID | <8ac8d5c0-096f-4425-a397-899151d6958e@googlegroups.com> |
| In reply to | #42497 |
Coos Haak, like Thanks Ching
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-10-09 16:00 +0000 |
| Message-ID | <2015Oct9.180048@mips.complang.tuwien.ac.at> |
| In reply to | #42497 |
Chris Curl <ccurl609@gmail.com> writes:
>If there is no word in the standard for it, what word do you folks use?
ABORT clears the stack (but also produces an error message in Gforth).
Gforth has CLEARSTACK (this only clears the data stack).
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2015-10-09 08:38 -1000 |
| Message-ID | <soydnfB8COcwlIXLnZ2dnUU7-V2dnZ2d@supernews.com> |
| In reply to | #42513 |
On 10/9/15 6:00 AM, Anton Ertl wrote: > Chris Curl <ccurl609@gmail.com> writes: >> If there is no word in the standard for it, what word do you folks use? > > ABORT clears the stack (but also produces an error message in Gforth). > > Gforth has CLEARSTACK (this only clears the data stack). Such a word should be used very rarely, and mostly in debugging. The reason is that you want your Forth words to be usable in any context; they should only affect their own immediate environment. The general rule is, a word should remove its arguments and leave only explicit results. It shouldn't touch anything else on the stack. When you're testing, it's often helpful to clear your stack and then put specific things on it and call the word or words you're testing, and ABORT is just fine for that case. 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 | Chris Curl <ccurl609@gmail.com> |
|---|---|
| Date | 2015-10-09 12:31 -0700 |
| Message-ID | <c97a0860-a3c4-4a9b-a476-86d62d0a5b25@googlegroups.com> |
| In reply to | #42522 |
On Friday, October 9, 2015 at 2:38:38 PM UTC-4, Elizabeth D. Rather wrote: > Such a word should be used very rarely, and mostly in debugging. The > reason is that you want your Forth words to be usable in any context; > they should only affect their own immediate environment. The general > rule is, a word should remove its arguments and leave only explicit > results. It shouldn't touch anything else on the stack. When you're > testing, it's often helpful to clear your stack and then put specific > things on it and call the word or words you're testing, and ABORT is > just fine for that case. > > Cheers, > Elizabeth > Understood and agreed. It is just that, as I'm sure you are well aware, spending alot of time developing a new word can result in lots of times where the stack has remnants on it, so clearing the stack is a very common thing, at least for me. Until now, I have just typed in an unknown word (like ..), which is fine. But I was wondering if there was word people commonly use or it, or even if there was one in the standard that I wasn't aware of.
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2015-10-09 10:29 -1000 |
| Message-ID | <Jpednf1yVIc_voXLnZ2dnUU7-K2dnZ2d@supernews.com> |
| In reply to | #42525 |
On 10/9/15 9:31 AM, Chris Curl wrote: > On Friday, October 9, 2015 at 2:38:38 PM UTC-4, Elizabeth D. Rather wrote: >> Such a word should be used very rarely, and mostly in debugging. The >> reason is that you want your Forth words to be usable in any context; >> they should only affect their own immediate environment. The general >> rule is, a word should remove its arguments and leave only explicit >> results. It shouldn't touch anything else on the stack. When you're >> testing, it's often helpful to clear your stack and then put specific >> things on it and call the word or words you're testing, and ABORT is >> just fine for that case. >> >> Cheers, >> Elizabeth >> > Understood and agreed. It is just that, as I'm sure you are well aware, > spending alot of time developing a new word can result in lots of > times where the stack has remnants on it, so clearing the stack is a > very common thing, at least for me. Until now, I have just typed in an > unknown word (like ..), which is fine. But I was wondering if there was > word people commonly use or it, or even if there was one in the standard > that I wasn't aware of. > If the remnants are things you know about (i.e., results) yes, this is very common, and .. is a fine practical solution, and the sort of thing most of us do. 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 | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-10-11 11:51 +1000 |
| Message-ID | <mvcbs7$4r0$1@speranza.aioe.org> |
| In reply to | #42525 |
Chris Curl wrote: > ... > Until now, I have just typed in an > unknown word (like ..), which is fine. But I was wondering if there was > word people commonly use or it, or even if there was one in the standard > that I wasn't aware of. In my experience it's rare for a program to need such a word, so (for me) your former method is fine and doesn't waste a word. The 'handy hint' Brodie suggests in Starting Forth (1st ed. p137) is shorter than ABORT and is exactly the one I use to this day - so much so it has become automatic. I couldn't use Forth without it :)
[toc] | [prev] | [next] | [standalone]
| From | Ching-Tang Tseng <ilikeforth@gmail.com> |
|---|---|
| Date | 2015-10-10 18:28 -0700 |
| Message-ID | <83148fa3-9fe8-432f-a9b8-37c327f0fca6@googlegroups.com> |
| In reply to | #42497 |
I had ever tried to design a FORTH system for our blind friend to use. It has sound output function. In that my personal experience, I felt use '''''''''''' Enter method is better, owing to the ' is the nearest one key to the Enter, even the blind friend is very ease to operate by right hand only.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-10-10 22:53 -0700 |
| Message-ID | <2862ed5a-b06f-4342-a3c1-5e49ff853526@googlegroups.com> |
| In reply to | #42558 |
On Saturday, October 10, 2015 at 6:28:11 PM UTC-7, Ching-Tang Tseng wrote: > I had ever tried to design a FORTH system for our blind friend to use. It has sound output function. > In that my personal experience, I felt use > '''''''''''' Enter > method is better, owing to the ' is the nearest one key to the Enter, even the blind friend is very ease to operate by right hand only. I've always just done this too --- I've never given any thought to defining a word specifically for it. If I did write such a word, I would give it a vulgar name though as I would only be using it in cases in which I had screwed up and needed to clean up a mess. ;-)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web