Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: suggestions for word names? Date: Fri, 14 Feb 2014 20:44:22 -0500 Organization: Aioe.org NNTP Server Lines: 44 Message-ID: References: NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; 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:28444 On Fri, 14 Feb 2014 15:15:48 -0500, Marcos Cruz wrote: > > I'm using the following two pieces of code in several words of mine: > > 2>r dup dup 2r> ( x1 x2 x3 -- x1 x1 x1 x2 x3 ) > > >r dup dup r> ( x1 x2 -- x1 x1 x1 x2 ) > > Each of them is used in two or three words (customized versions of 'of', > e.g. 'within-of', 'greater-of', etc.), and the list is expected to > grow, so they are good candidates for factoring. > > Does anybody know any words (common usage or provided by any Forth > system or library), that do the same than those code pieces? > I don't know what they'd be called, but you might be able to improve that code slightly. For the fist sequence "2>r dup dup 2r>", the 2>r and 2r> are likely to be very expensive operations timewise. That sequence is also equivalent to this: >r nup nup r> Even though nup isn't likely to be very efficient either, eliminating 2>r and 2r> is likely to speed things up. The second sequence ">r dup dup r>" is: nup nup It's not likely that "nup nup" outperforms ">r dup dup r>" for your Forth, but it might. This depends on how efficiently nup is implemented as compared to how efficiently >r and r> are and how much call overhead per Forth word there is. nup ( x1 x2 -- x1 x1 x2 ) Rod Pemberton