Path: csiph.com!usenet.pasdenom.info!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:27979 On Mon, 20 Jan 2014 01:54:25 -0500, Elizabeth D Rather wrote: > On 1/19/2014 7:27 PM, Rod Pemberton wrote: > I'm baffled. CREATE makes a header; :NONAME doesn't. CREATE > doesn't turn on the compiler. :NONAME does. These differences > are critical, not trivial. > Based on your post and Mark's, I think my :NONAME is functioning like :NONAME combined with HEADER. >>> It sounds as though you have a very >>> mistaken notion of what :NONAME does. >> >> AIUI, :NONAME is the same as : except it doesn't install >> a name into the dictionary header of the word being defined >> and it returns an xt. It's definition is terminated by >> a ; just like a : definition. It compiles a definition >> just like a : definition. >> >> In most Forths, : calls CREATE to build the header >> and insert the name the word being defined. After >> CREATE is finished, the colon definition continues >> compiling until ; . > > In most Forths that I'm familiar with, : calls a lower-level word to > build the header and insert the name. CREATE also calls that. However, > CREATE does *not* "continue compiling", instead it sets the default > action of the word just created to DODOES or equivalent with an > associated data location. : has no associated data location. In other > words, the only thing both : and CREATE share is a call to the > lower-level word to make the header. > Let me break down what I'm doing currently. It's been a while since I've read/coded the code, so hopefully, no misunderstandings/mistakes posted... This is what :NONAME CREATE : and ; are doing: :NONAME -the next few steps creates a dictionary header --blanks name field area (NFA) --updates link field address (LFA) with LAST --updates dictionary bits (part of NFA) --updates LAST --updates dictionary pointer (DP) to code field address (CFA) -puts HERE (at current CFA) on the stack for use as an XT -compiles ENTER into the definition (at current CFA) -turns on compiling ] -SMUDGEs the definition being compiled (turns on) : -executes :NONAME -executes BL WORD to get name of definition -executes COUNT -sets up values for CMOVE which consumes :NONAMEs XT -finds the name field (NFA) -executes CMOVE to move the definition's name into the name field ; -compiles EXIT into a definition -SMUDGEs the definition being compiled (turns off) -turns off compiling [ CREATE -executes : -places HERE on the stack -executes ; -sets the dictionary pointer (DP) to code field address (CFA) -stores DOVAR into the code field address (CFA) -resets dictionary pointer (DP) to saved HERE on stack > Consider the definition: > > : CONSTANT ( n -- ) CREATE , > DOES> ( -- n ) @ ; > > Here CREATE builds the header and , compiles the value in data space. > The fact that compiling continues is not due to CREATE, which has > finished executing, but to : which invoked CREATE and , and continued > compiling. > All the common definitions which use CREATE work correctly. >> AIUI, all I've done is switch things around to build >> : up from :NONAME instead of using CREATE. If it's >> correct, which I believe it is, > from :NONAME also. > > does not: build a header, and associate a data space > address. :NONAME turns on the compiler and records the > *code space* location of the associated xt, > neither of which > They have *nothing* in common. > > The distinction between code space and data space is critical > when you're dealing with RAM/FLASH architectures. > Okay, I suspect you're going to tell me to remove the header creation in :NONAME and place it into a word named HEADER or (CREATE). Then, have : call HEADER or (CREATE). So, then, the rough definition for : would become: : HEADER :NONAME BL WORD COUNT ... "get NFA" CMOVE ; I'm assuming the rest is acceptable ... ? IIRC, :NONAME on my system needed a header for the dictionary to be linked together correctly. If so, I'll have to check into why that is... It's probably wise to fix the issue. Rod Pemberton