xt to name in ANS? 
Author Message
 xt to name in ANS?

Is there a way to convert the execution token to the forth word name
using ANS Forth? In other words, something like the opposite of FIND.

RdR



Tue, 25 Jan 2000 03:00:00 GMT  
 xt to name in ANS?



Quote:
> Is there a way to convert the execution token to the forth word name
> using ANS Forth? In other words, something like the opposite of FIND.

Some systems have >NAME or >LINK but this does not appear in either the
ANS or ISO standards. It would, I think, have been a nice inclusion.

I prefer >NAME for this word.

Other words of the group would be:

Quote:
>BODY and BODY>

--

Transport Control Technology Ltd.   <http://www.tcontec.demon.co.uk/>

Going Forth Safely


Tue, 25 Jan 2000 03:00:00 GMT  
 xt to name in ANS?

Quote:


> > Is there a way to convert the execution token to the forth word
> > name using ANS Forth? In other words, something like the opposite
> > of FIND.

> Some systems have >NAME or >LINK but this does not appear in either
> the ANS or ISO standards. It would, I think, have been a nice
> inclusion.

If you think about this is not possible.  Once you use >BODY, >NAME,

Quote:
>LINK or any such word, you have started to make assumptions about the internals of the compiler (the existence and format of the name filed). Unlike previous standards the ANS and thus the ISO standards do not impose an implementation model.

There is no reason an ANS Forth system could not provide these words,
but any program that uses them will not be an ANS Forth program.

--
Peter Knaggs



Tue, 25 Jan 2000 03:00:00 GMT  
 xt to name in ANS?



Quote:


> > > Is there a way to convert the execution token to the forth word
> > > name using ANS Forth? In other words, something like the opposite
> > > of FIND.

> > Some systems have >NAME or >LINK but this does not appear in either
> > the ANS or ISO standards. It would, I think, have been a nice
> > inclusion.

> If you think about this is not possible.  Once you use >BODY, >NAME,
> >LINK or any such word, you have started to make assumptions about the
>  internals of the compiler (the existence and format of the name filed). Unlike
>  previous standards the ANS and thus the ISO standards do not impose an
>  implementation model.

> There is no reason an ANS Forth system could not provide these words,
> but any program that uses them will not be an ANS Forth program.

I think, Peter, you read more into my response than I intended. I did not
claim that it was standard and that any programme using these words would be.
I just pointed out that some systems used such words.

Now, ANS and ISO standards do have some of the words you mentioned. >BODY is
definitely in. It would not have been a problem to specify >NAME and >LINK
in the standard. There are ways in which these could be implemented in
implementation dependent ways but still work in a standard specificed form.

I would expect that >NAME would take the xt and return the address of the
name space (counted string). This could happen whether or not the name was
actually on the Host or Target of an umbilcally connected, whether or not
the headers were separated. If there was no name attached, a false flag
could be returned and the programme would then not perform the action it
would have done if there had been a name. I would have thought it simple
enough.

--

Transport Control Technology Ltd.   <http://www.tcontec.demon.co.uk/>

Going Forth Safely



Tue, 25 Jan 2000 03:00:00 GMT  
 xt to name in ANS?


Quote:

>Is there a way to convert the execution token to the forth word name
>using ANS Forth? In other words, something like the opposite of FIND.

No.  There isn't.

Some standard Forths might have the name in a separate namespace that
is thrown away.  Some might hash the names or do something else that
keeps them from being recovered.

There is a way to do it in Forth-83, with >NAME .  You could use that
and it will work on all standard Forth systems that implement it, which
will be a lot.  After all, if you _can_ set it up to get names back,
you might as well use >NAME to do it.  Unless of course the names are
stored in a place or in a way that TYPE etc don't work right.  For
example they could be in a different segment and TYPE works only on the
data segment.  OK, the name I've heard that gets used pretty often to
print out a name given an xt is .ID .  I don't think it's in any
standard but it could be fairly common practice.

If you really need to have the names, and you really need it to run on
random standard systems, you can redefine all the defining words to do
it.  Like:

: VARIABLE ( -- aa )

   1 CELLS ALLOT
   DOES>  COUNT + ;

: CONSTANT ( -- x )


etc.

: >NAME ( xt -- ca )
   >BODY ;
: >BODY ( xt -- aa )
   >BODY COUNT + ;

What this does is to store an extra name field for every definition.
Then you'll be able to get the names of everything you define.  You'll
get garbage for all the pre-existing commands, of course.  You can fix
that by redefining them to store the name and then call the old
version.

Needless to say, this costs a certain amount of space and a significant
amount of time.  It is _possible_ in standard Forth, if you really need
to.

Come to think of it, you'd have less overhead if you stored the xt's
and names in big tables and did a lookup.  Yeah, that's the ticket.



Tue, 25 Jan 2000 03:00:00 GMT  
 xt to name in ANS?

Quote:

> Is there a way to convert the execution token to the forth word name
> using ANS Forth? In other words, something like the opposite of FIND.

No. There was a mailing list about standardizing Forth's internals, but
it's dead, Jim. Gforth uses >NAME NAME>STRING, thus

' words >name name>string type

gives

words

--
Bernd Paysan
"Late answers are wrong answers!"
http://www.informatik.tu-muenchen.de/~paysan/



Wed, 26 Jan 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. XTs and ANS (was TESTING POSTPONE)

2. IT as the name for returning last xt

3. Ada bindings to Xt, DOS versions of Xlib or Xt

4. Ans Cross vs. GForth name collisions

5. ANS question on names

6. ANS Forth file name extensions--consensus?

7. ANS Forth in ANS Forth?

8. XT/X...any new web pages?

9. Clipper on Windows-XT: GPF Error

10. to xt's from KEY sequences

11. DOES> changing behaviour of an xt

12. Forth for DOS on XT

 

 
Powered by phpBB® Forum Software