Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.etla.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: quick review of 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:28056 On Fri, 24 Jan 2014 04:28:46 -0500, Mark Wills wrote: > I think the RECURSE with :NONAME issue is fairly easy to work around, > Rod. > > You currently read LATEST to get to the CFA of the last defined word > (maybe you convert from a link field address to a CFA, no matter). That > all seems correct to me. But with a small change to ; :NONAME and > RECURSE you can solve the problem: > > Define an extra variable, called NoNameCFA. RECURSE will use this to > determine if a :NONAME definition is currently being built. > > Modify ; to zero out the NoNameCFA variable: > > : ; 0 NoNameCFA ! ; IMMEDIATE > > Modify :NONAME such that it loads NoNameCFA with the CFA of the NONAME > definition currently under construction, which will be easy to compute. > It's probably just HERE. > > : :NONAME HERE @ NoNameCFA ! ; > > Now, RECURSE, which is IMMEDIATE, checks NoNameCFA before checking > LATEST: > > : RECURSE ( -- ) > NoNameCFA @ DUP IF , ELSE DROP LATEST @ >CFA , THEN ; IMMEDIATE > > Et voila. > > The new code in ; will zero out NoNameCFA at the end of the NONAME > definition, so RECURSE will work in the next colon definition: > > : THING 1000 RND RECURSE ; > > See? When RECURSE (being immediate) executes in this colon definition, > NoNameCFA was 0, because the terminating ; in the previous NONAME zero'd > it. Thus RECURSE will use the ELSE leg of it's code, and compile a > reference via LATEST. > > Hope my rambling makes sense! Well, I was considering something like using LAST with LATESTXT. Perhaps it should be called LASTXT since I'm using LAST instead of LATEST ... ? Lars mentioned it for Gforth, but it was also mentioned in regards to Win32Forth by Alex. This was in the 2012 thread (June ?) where you brought up the issue with :NONAME and RECURSE. Without a header on :NONAME , it seems to really need another variable to keep track of the XT for RECURSE , if you want RECURSE to work with :NONAME . LATESTXT or somesuch variable ( LASTXT or perhaps RCRS) seems to be LAST , but it's also updated for the CFA to a :NONAME definition. For : , I was considering just copying LAST into the new variable. For :NONAME , I was considering copying HERE into the new variable. For RECURSE , I was considering changing it to use the new variable instead of using LAST. I think that would be sufficient. I can't attempt this for a while. I've got to back out and fix all the other stuff... HTH, Rod Pemberton