Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Static Single Assignment form to Stack allocation Date: Sat, 07 Feb 2015 21:05:30 -0500 Organization: Aioe.org NNTP Server Lines: 36 Message-ID: References: <82c4c3dc-7692-4d03-a447-9bdd54ff9387@googlegroups.com> <2015Feb6.142225@mips.complang.tuwien.ac.at> <26b59aed-f1a6-4ccb-90ad-69c36b1abb89@googlegroups.com> <45da3660-ad44-4d81-9142-e8582e5d66d2@googlegroups.com> <2fWdnbgKv_RXH0vJnZ2dnUU7-TGdnZ2d@supernews.com> <9b851120-bcf2-41ba-851a-49dcf5654736@googlegroups.com> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:36378 On Sat, 07 Feb 2015 17:09:06 -0500, Aliaksei Chapyzhenka wrote: > On Saturday, February 7, 2015 at 1:25:31 PM UTC-8, Elizabeth D. Rather > wrote: >> On 2/7/15 11:09 AM, Aliaksei Chapyzhenka wrote: >> > It is common to store return address or loop counter there, but >> > also temporal shuffling data from parameter stack and back... >> >> : 2SWAP ROT >R ROT R> ; >> >> That is a singularly awkward and inefficient definition of 2SWAP. > > Yes, especially I we define : ROT >R SWAP R> SWAP ; If you avoid ROT and OVER in 2SWAP's definition, the next shortest sequence in *Forth* code, using low-level Forth words, is: : 2SWAP >R SWAP R> SWAP >R >R SWAP r> SWAP R> ; I can be argue that that is even less efficient. So, I'm not sure what Alex's point was. Perhaps, he meant that non-Forth stack operations could implement the sequence better ... ? > But what [else] would you do on the stack machine without PICK with > core set of Forth words: DROP DUP SWAP OVER >R R> R@ ? Without PICK and the reverse operation, perhaps PLACE , you can't directly obtain values from the stack or store values directly into the stack. You'd have to do things the Forth way, which is to move everything to the return stack, perform the save/retrieve, move everything back to the data stack from the return stack. This is why non-Forth languages don't implement stack code in this manner. Rod Pemberton