Defining variables automatically 
Author Message
 Defining variables automatically

I'm wondering if it is possible to define a word that then defines
new variables when it is executed.  That is,

: NewWord    100 [COMPILE] VARIABLE ;

The problem is, that when you call `NewWord' it prompts you for
a variable name (as it should, logically speaking).

The question then, is, can the input be redirected somehow for
the purpose of entering the variable names?

  Ralph Siemsen

Fri, 02 Jun 1995 05:39:56 GMT  
 Defining variables automatically


>I'm wondering if it is possible to define a word that then defines
>new variables when it is executed.  That is,

        You ask if input to the VARIABLE''s name generation can be
redirected. It can, in most systems. The trick is to change the source
of the input stream.

        This can be done in a number of ways. In ANS Forth, it will
be regularized. SAVE-INPUT and RESTORE-INPUT handle preserving
the current input stream. Then input can be obtained from the user,
from a file, from an arbitrary character-address + count.


 # du!isis!koscej!jax        # # X3J14 TC # #  Forth Interest Group #
 # JAX on GEnie              # # for ANS  # #   P.O. Box 2154       #
 # SYSOP RCFB (303) 278-0364 # #  Forth   # #    Oakland, CA 94621  #

Fri, 02 Jun 1995 15:50:26 GMT  
 Defining variables automatically
This is an interesting point. I was tinkering around with some published code
which did some fancy footwork with the input stream. Unfortunately I could
not understand the code. Since the author had done such a good job on the
rest of the code I could only conclude his code was sound, and that my
understanding of the compiler (L&P) was faulty. Very unsatisfying. And a good
argument for a well thought out standard. Why should I be compelled to
understand a specific implementation to understand the code.

regards john
john somerville B.C. Hydro
affiliations FIG Forth Interest Group

Sat, 03 Jun 1995 14:55:55 GMT  
 [ 3 post ] 

 Relevant Pages 

1. FYI: Automatically BIND variables

2. instance variables automatically accessible?

3. automatically naming a global variable

4. g77 that automatically define the real variable (not use real*8) to double precision?

5. How do I define a Global Variable?

6. Define INI file path using a variable

7. How to define variable key-filenames?

8. Define <Variable Name>

9. define "variable" word

10. Defining an user variable in Win32Forth

11. local variable of a reference to a user defined control - how much memory it takes

12. how to define global variables?


Powered by phpBB® Forum Software