Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #28625 > unrolled thread
| Started by | "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> |
|---|---|
| First post | 2014-02-20 16:30 -0500 |
| Last post | 2014-03-08 18:40 -0500 |
| Articles | 16 on this page of 36 — 16 participants |
Back to article view | Back to comp.lang.forth
top 10 words which should *not* be in a Forth dictionary? "Rod Pemberton" <dont_use_email@xnohavenotit.cnm> - 2014-02-20 16:30 -0500
Re: top 10 words which should *not* be in a Forth dictionary? AKK <akk@nospam.org> - 2014-02-20 23:56 +0100
Re: top 10 words which should *not* be in a Forth dictionary? Coos Haak <chforth@hccnet.nl> - 2014-02-21 02:40 +0100
Re: top 10 words which should *not* be in a Forth dictionary? hughaguilar96@yahoo.com - 2014-02-20 21:17 -0800
Re: top 10 words which should *not* be in a Forth dictionary? Syd Rumpo <usenet@nononono.co.uk> - 2014-02-21 13:58 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2014-02-21 11:04 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Hans Bezemer <the.beez.speaks@gmail.com> - 2014-02-22 17:10 +0100
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-02-22 13:15 -0600
Re: top 10 words which should *not* be in a Forth dictionary? "Alex McDonald" <blog@rivadpm.com> - 2014-02-22 21:46 +0000
Re: top 10 words which should *not* be in a Forth dictionary? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-02-23 15:42 +0000
Re: top 10 words which should *not* be in a Forth dictionary? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-02-23 15:46 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Assad Ebrahim <assadebrahim2000@gmail.com> - 2014-03-03 12:08 -0800
Re: top 10 words which should *not* be in a Forth dictionary? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-03 20:23 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-03 15:58 -0600
Re: top 10 words which should *not* be in a Forth dictionary? Coos Haak <chforth@hccnet.nl> - 2014-03-04 01:06 +0100
Re: top 10 words which should *not* be in a Forth dictionary? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-03-06 18:01 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-06 17:59 -0600
Re: top 10 words which should *not* be in a Forth dictionary? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-03-07 11:34 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-07 06:43 -0600
Re: top 10 words which should *not* be in a Forth dictionary? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-03-07 13:07 +0000
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-07 08:41 -0600
Re: top 10 words which should *not* be in a Forth dictionary? Assad Ebrahim <assadebrahim2000@gmail.com> - 2014-03-07 10:17 -0800
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-07 13:10 -0600
Re: top 10 words which should *not* be in a Forth dictionary? Assad Ebrahim <assadebrahim2000@gmail.com> - 2014-03-07 11:32 -0800
Re: top 10 words which should *not* be in a Forth dictionary? Lars Brinkhoff <lars.spam@nocrew.org> - 2014-03-07 14:28 +0100
Re: top 10 words which should *not* be in a Forth dictionary? Assad Ebrahim <assadebrahim2000@gmail.com> - 2014-03-07 22:59 -0800
Re: top 10 words which should *not* be in a Forth dictionary? Coos Haak <chforth@hccnet.nl> - 2014-03-08 08:33 +0100
Re: top 10 words which should *not* be in a Forth dictionary? "Elizabeth D. Rather" <erather@forth.com> - 2014-03-07 23:21 -1000
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-08 04:30 -0600
top 10 words which should *not* be in a Forth dictionary? Mark Wills <markwills1970@gmail.com> - 2014-03-08 03:27 -0800
Re: top 10 words which should *not* be in a Forth dictionary? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-03-08 05:36 -0600
Re: top 10 words which should *not* be in a Forth dictionary? Mark Wills <markwills1970@gmail.com> - 2014-03-08 15:39 -0800
Re: top 10 words which should *not* be in a Forth dictionary? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-03-08 14:02 +0000
Re: top 10 words which should *not* be in a Forth dictionary? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-08 17:20 -0500
Re: top 10 words which should *not* be in a Forth dictionary? "Elizabeth D. Rather" <erather@forth.com> - 2014-03-08 12:36 -1000
Re: top 10 words which should *not* be in a Forth dictionary? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-03-08 18:40 -0500
Page 2 of 2 — ← Prev page 1 [2]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2014-03-07 08:41 -0600 |
| Message-ID | <cdadnZ8xV6wCR4TOnZ2dnUVZ_hCdnZ2d@supernews.com> |
| In reply to | #28954 |
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: > Andrew Haley <andrew29@littlepinkcloud.invalid> writes: >>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes: >>>>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >>>>> Andrew Haley <andrew29@littlepinkcloud.invalid> writes: >>>>>> Here's DFS for a binary tree: >>>>>> >>>>>> : inorder ( a) >>>>>> 0 swap >>>>>> begin >>>>>> begin ?dup while dup left @ repeat >>>>>> ?dup while >>>>>> dup visit >>>>>> right @ >>>>>> repeat ; > ... >>> Ok, if you wanted to show that, you totally failed to get that across, >>> by both writing obscure code, as well as not mentioning it at all in >>> the text. >> >>Heh. I like the code. So there. > > Ok, so you like undocumented code without stack comments, that call > unspecified words. I'll grant you this snippet is undocumented, but I don't think it needs it in this context. >>Assad's question was "how would you code an algorithm that's naturally >>recursive (e.g. DFS) [without RECURSE]?" The example code above, >>being an implementation of a recursive algorithm without explicit >>recursion, is a valid answer to that question. > > Sure, but an uncomprehensible answer is neither helpful for Assad nor > for everybody else. It's uncomprehensible (sic) to some, perhaps, but I don't think it's unreasonable to credit the reader with some knowledge and imagination. The words VISIT, LEFT, and RIGHT, are pretty obvious. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Assad Ebrahim <assadebrahim2000@gmail.com> |
|---|---|
| Date | 2014-03-07 10:17 -0800 |
| Message-ID | <153047df-e0d7-4828-8455-d6bd475bd262@googlegroups.com> |
| In reply to | #28959 |
On Friday, March 7, 2014 2:41:35 PM UTC, Andrew Haley wrote: > Anton Ertl <anton@m...> wrote: > > Andrew Haley <andrew29@...> writes: > > > > Sure, but an uncomprehensible answer is neither helpful for Assad nor > > for everybody else. > > It's uncomprehensible (sic) to some, perhaps, but I don't think it's > unreasonable to credit the reader with some knowledge and imagination. > The words VISIT, LEFT, and RIGHT, are pretty obvious. > > Andrew. I should probably weigh in here. Firstly, thanks for the answer Andrew (and Albert and Coos as well). Yes, Andrew's interpretation was correct --- my question arose out of curiousity thinking that for Andrew to say he does not think RECURSE should be a word in Forth must mean that he has some other way of coding algorithms that are often done using recursion. His code example showed another approach, which was interesting to see. Anton's interpretation (I think) is also fair --- i.e. if the word RECURSE is removed, then is there any way to code a recursive algorithm in Forth *using* recursion? And I think Andrew & Coos combined to answer that with a Factorial example using DEFER. As far as the code example itself, yes, it did take a little more effort to follow, so, certainly stack comments and text explanations would always help, but if I were to choose between someone not bothering to answer at all or answering perhaps with less documented code, I would still rather the former. In the end, it's a pretty active forum, Andrew is pretty active, and I'm sure that if I or anyone else asked for more clarification on the undocumented code, Andrew, or someone else, would probably fill in the gaps.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2014-03-07 13:10 -0600 |
| Message-ID | <N76dnRIryJBehIfOnZ2dnUVZ_s-dnZ2d@supernews.com> |
| In reply to | #28962 |
Assad Ebrahim <assadebrahim2000@gmail.com> wrote:
> I should probably weigh in here.
Please. :-)
> As far as the code example itself, yes, it did take a little more
> effort to follow, so, certainly stack comments and text explanations
> would always help, but if I were to choose between someone not
> bothering to answer at all or answering perhaps with less documented
> code, I would still rather the former.
I confess, it was something of an exercise for the reader. :-)
Stack comments for that one are an interesting challenge. The idea
isn't at all complex, and the Forth doesn't look all that bad, but it
is subtle:
: inorder ( a)
0 swap
begin
begin
?dup while
\ Go as far as we can down the left subtrees, pushing trees
\ as we go
dup left @
repeat ( 0 a0 a1 a2 ... aN)
\ We now have a stack of trees. The tree on top is empty or
\ has no left node
?dup while \ If the tree on top is empty, the algorithm terminates
dup visit ( 0 a0 a1 a2 ... aN)
\ Fetch the right subtree and traverse it
right @
( 0 a0 a1 a2 ... aN-1 aN.right)
repeat ;
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Assad Ebrahim <assadebrahim2000@gmail.com> |
|---|---|
| Date | 2014-03-07 11:32 -0800 |
| Message-ID | <f07c62ec-0a73-4db4-91c3-265e59f24e44@googlegroups.com> |
| In reply to | #28962 |
On Friday, March 7, 2014 6:17:07 PM UTC, Assad Ebrahim wrote: > > but if I were to choose between someone not bothering to answer at all or > answering perhaps with less documented code, I would still rather the former. > Sorry, just realised that a last minute edit switching the clauses around without fixing the reference garbled this up and reversed my meaning entirely. What I meant to say was: "...but if I were to choose between someone not bothering to answer at all or answering with less documented code, I would still rather the LATTER", i.e. some answer is better than no answer... Well, stack order problems affect hastily edited English just as much as code ;) - Assad
[toc] | [prev] | [next] | [standalone]
| From | Lars Brinkhoff <lars.spam@nocrew.org> |
|---|---|
| Date | 2014-03-07 14:28 +0100 |
| Message-ID | <85fvmu5ea1.fsf@junk.nocrew.org> |
| In reply to | #28950 |
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes: > Andrew Haley <andrew29@littlepinkcloud.invalid> writes: >> A more interesting one is to show that Forth, because of the data >> stack, doesn't need recursion as often as some other languages do. > Ok, if you wanted to show that, you totally failed to get that > across, by both writing obscure code, as well as not mentioning it > at all in the text. Not totally. You may be right that it was obscure, but I understood his message on my first reading of CKydnXPWBpSQZonOnZ2dnUVZ_oidnZ2d@supernews.com.
[toc] | [prev] | [next] | [standalone]
| From | Assad Ebrahim <assadebrahim2000@gmail.com> |
|---|---|
| Date | 2014-03-07 22:59 -0800 |
| Message-ID | <f3cd8fde-db4e-4abc-abca-cab623697e39@googlegroups.com> |
| In reply to | #28690 |
On Saturday, February 22, 2014 4:10:54 PM UTC, The Beez wrote: > PICK, ROLL - for reasons Brodie mentioned Isn't PICK needed to display the stack without alternating it? E.g. for .S? - Assad
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2014-03-08 08:33 +0100 |
| Message-ID | <wt8pmqppuw5c.11ppjqxyqrs5e$.dlg@40tude.net> |
| In reply to | #28971 |
Op Fri, 7 Mar 2014 22:59:37 -0800 (PST) schreef Assad Ebrahim:
> On Saturday, February 22, 2014 4:10:54 PM UTC, The Beez wrote:
>> PICK, ROLL - for reasons Brodie mentioned
>
> Isn't PICK needed to display the stack without alternating it? E.g. for .S?
>
> - Assad
Not necessarily, there are systems, like colorforth that even don't have
DEPTH and can't implement PICK. But if you have DEPTH you can do this:
: .s
." ( " depth
if depth dup
begin dup
while rot >r 1-
repeat
drop
begin dup
while r> tuck . 1-
repeat
drop
then
." ) "
;
--
Coos
CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2014-03-07 23:21 -1000 |
| Message-ID | <HY6dnaCCWe9ifYfOnZ2dnUVZ_sCdnZ2d@supernews.com> |
| In reply to | #28971 |
On 3/7/14 8:59 PM, Assad Ebrahim wrote: > On Saturday, February 22, 2014 4:10:54 PM UTC, The Beez wrote: >> PICK, ROLL - for reasons Brodie mentioned > > Isn't PICK needed to display the stack without alternating it? E.g. for .S? .S is generally considered to be a facility that a system should provide, rather than a user-supplied function. A system has to do a lot of things that may or may not be visible to users. I believe this thread is discussing what functions should be available for user programming. My personal philosophy is that Forth should be written in Forth, and all of its underpinnings should be available to users. So, even though I generally abhor using PICK and ROLL in programs, I agree with you that PICK, at least, is useful in systems for the purpose you suggest, and therefore should be "in the dictionary". 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 | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2014-03-08 04:30 -0600 |
| Message-ID | <tsqdnWsNouCobIfOnZ2dnUVZ_smdnZ2d@supernews.com> |
| In reply to | #28971 |
Assad Ebrahim <assadebrahim2000@gmail.com> wrote: > On Saturday, February 22, 2014 4:10:54 PM UTC, The Beez wrote: >> PICK, ROLL - for reasons Brodie mentioned > > Isn't PICK needed to display the stack without alternating it? E.g. for .S? On the theme of recursion again, defer .s :noname depth if >r .s r> dup . else cr then ; is .s or : .s depth if >r recurse r> dup . else cr then ; This is less efficient than using PICK would be, at least on a conventional processor. And it uses a lot of return stack space. Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2014-03-08 03:27 -0800 |
| Message-ID | <c29870fd-af6f-4011-8eba-5d659d656ef7@googlegroups.com> |
| In reply to | #28625 |
ROT and -ROT. As descriptive words they suck. Neither of them describe the direction in which they rotate. Every freaking time I need them I need to look them up. Why can't they be called be LROT and RROT. Grrr...
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2014-03-08 05:36 -0600 |
| Message-ID | <3OGdna2u6NE4nYbOnZ2dnUVZ8judnZ2d@supernews.com> |
| In reply to | #28976 |
Mark Wills <markwills1970@gmail.com> wrote: > ROT and -ROT. As descriptive words they suck. Neither of them > describe the direction in which they rotate. Every freaking time I > need them I need to look them up. That's what the juggler image is for. Keep her in your mind and you'll be OK. http://www.forth.com/starting-forth/images/ch2-rot.gif Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2014-03-08 15:39 -0800 |
| Message-ID | <95746ba2-f4b3-4ae6-a350-5b10024007da@googlegroups.com> |
| In reply to | #28977 |
Yes. You're right. The juggler works. I'll commit her to memory. Shame she isn't better looking ;-) Thanks
[toc] | [prev] | [next] | [standalone]
| From | albert@spenarnc.xs4all.nl (Albert van der Horst) |
|---|---|
| Date | 2014-03-08 14:02 +0000 |
| Message-ID | <531b2303$0$24935$e4fe514c@dreader36.news.xs4all.nl> |
| In reply to | #28976 |
In article <c29870fd-af6f-4011-8eba-5d659d656ef7@googlegroups.com>, Mark Wills <markwills1970@gmail.com> wrote: >ROT and -ROT. As descriptive words they suck. Neither of them describe >the direction in which they rotate. Every freaking time I need them I >need to look them up. Why can't they be called be LROT and RROT. In yourforth they are called SDSWAP (swap a single and a double) and DSSWAP (swap a double and a single). Reorder three stack items is so so, otoh swapping a stringconstant and an address is not so bad. The pons asinorum is that ROT and SDSWAP are the canonical ones. min_rote and dee_ess_swap are akward. > >Grrr... Hope this helps. I find it often much easier to keep the order intact and remember things on the return stack. 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 | "Rod Pemberton" <dont_use_email@xnothavet.cqm> |
|---|---|
| Date | 2014-03-08 17:20 -0500 |
| Message-ID | <op.xcfccz1b6zenlw@localhost> |
| In reply to | #28976 |
On Sat, 08 Mar 2014 06:27:26 -0500, Mark Wills <markwills1970@gmail.com> wrote: > ROT and -ROT. As descriptive words they suck. Neither of them describe > the direction in which they rotate. Every freaking time I need them I > need to look them up. Why can't they be called be LROT and RROT. > For x86, I can never remember when, before or after, or which direction, incremented or decremented, the stack pointer is adjusted for PUSH and POP. So, I use a mnemonic abbreviation, POPIA - POP Increments After. -ROT pops the 3rd to the top. That sort of rhymes... ROT pushes. Rod Pemberton
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2014-03-08 12:36 -1000 |
| Message-ID | <ybydnazI55zHBobOnZ2dnUVZ_vSdnZ2d@supernews.com> |
| In reply to | #28987 |
On 3/8/14 12:20 PM, Rod Pemberton wrote: > On Sat, 08 Mar 2014 06:27:26 -0500, Mark Wills <markwills1970@gmail.com> > wrote: > >> ROT and -ROT. As descriptive words they suck. Neither of them describe >> the direction in which they rotate. Every freaking time I need them I >> need to look them up. Why can't they be called be LROT and RROT. >> > > For x86, I can never remember when, before or after, or which direction, > incremented or decremented, the stack pointer is adjusted for PUSH and POP. > So, I use a mnemonic abbreviation, POPIA - POP Increments After. > > -ROT pops the 3rd to the top. That sort of rhymes... ROT pushes. Um, that's backwards. 6.1.2160 ROT “rote” CORE ( x1 x2 x3 -- x2 x3 x1 ) Rotate the top three stack entries. ROT brings the 3rd item to the top. 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 | "Rod Pemberton" <dont_use_email@xnothavet.cqm> |
|---|---|
| Date | 2014-03-08 18:40 -0500 |
| Message-ID | <op.xcff2bvz6zenlw@localhost> |
| In reply to | #28988 |
On Sat, 08 Mar 2014 17:36:09 -0500, Elizabeth D. Rather <erather@forth.com> wrote: > On 3/8/14 12:20 PM, Rod Pemberton wrote: >> On Sat, 08 Mar 2014 06:27:26 -0500, Mark Wills <markwills1970@gmail.com> >> wrote: >>> ROT and -ROT. As descriptive words they suck. Neither of them describe >>> the direction in which they rotate. Every freaking time I need them I >>> need to look them up. Why can't they be called be LROT and RROT. >> >> For x86, I can never remember when, before or after, or which direction, >> incremented or decremented, the stack pointer is adjusted for PUSH and >> POP. >> So, I use a mnemonic abbreviation, POPIA - POP Increments After. >> >> -ROT pops the 3rd to the top. That sort of rhymes... ROT pushes. > > Um, that's backwards. > > 6.1.2160 ROT “rote” CORE ( x1 x2 x3 -- x2 x3 x1 ) > Rotate the top three stack entries. > > ROT brings the 3rd item to the top. > Heh! So true... That makes a mnemonic abbreviation easier: ROTPT - ROT Pops (to) Top Rod Pemberton
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.forth
csiph-web