Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Rod Pemberton Newsgroups: comp.lang.forth Subject: Re: Stack Operator Symbols Date: Thu, 27 Oct 2016 19:13:45 -0400 Organization: Aioe.org NNTP Server Lines: 45 Message-ID: <20161027191345.4f524e44@_> References: <4e481228-bd80-4e39-a629-90a690e50756@googlegroups.com> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Claws Mail 3.13.1 (GTK+ 2.24.13; x86_64-unknown-linux-gnu) Xref: csiph.com comp.lang.forth:52254 On Mon, 24 Oct 2016 20:42:59 -0700 (PDT) trans wrote: > A paper called Stack Quarks by Rob Chapman[2] gives one way to look > at it, though it is very hardware oriented. He gives six elemental > operations which can be combined to make the operations we use in > Forth. For example, a DROP is DIP NIP, and DUP is a NUP DRIP. But I > don't see how he accounts for, say, swapping the NOS and the top of > the remaining stack (the third item). : NIP SWAP DROP ; : TUCK SWAP OVER ; : NUP OVER SWAP ; : DIP DROP DUP ; : TAKE DROP SWAP ; : DRIP SWAP DIP ; > Of course, what are the fundamental stack operations? > [...] > In any case, the operations from a coder's perspective are probably > the more pertinent operations for a symbolic notation, the > fundamental operations seem to me to be: > > drop > dup > swap > push (>r) > pull (r>) > > With these five I think all others are possible. Do you agree? Generally, you need DUP DROP SWAP >R R> to create the other single-cell stack operators, efficiently. Likewise, it's more efficient for double-cell operators if you have 2DUP DROP 2SWAP 2>R 2R> available. However, all the double-cell operators can be created using single-cell operators DUP DROP SWAP >R R> . Unfortunately, the length of some these double-cell definitions can become very long, e.g., 18 to 22, when using single-cell operations. Alternately, you can use PICK ROLL -ROLL SWAP DROP. Note that PICK ROLL -ROLL take a size argument. Rod Pemberton