home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / forth / 3655 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  3.9 KB

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!spool.mu.edu!olivea!charnel!fish
  2. From: fish@ecst.csuchico.edu (Kevin Haddock)
  3. Newsgroups: comp.lang.forth
  4. Subject: Re: Question: programming practice
  5. Message-ID: <1h5ojlINN9lm@charnel.ecst.csuchico.edu>
  6. Date: 22 Dec 92 00:47:49 GMT
  7. References: <BzMquL.2CE@news.iastate.edu>
  8. Organization: California State University, Chico
  9. Lines: 106
  10. NNTP-Posting-Host: cscihp.ecst.csuchico.edu
  11.  
  12. In article <BzMquL.2CE@news.iastate.edu> bible@iastate.edu (Anthony E Bible) writes:
  13. >
  14. >    I am writing a little program in which it is most reasonable to name a
  15. >couple of the words AND and IMMEDIATE.  
  16. [deleted]
  17. > having a "bunch" of vocabulary bookkeeping stuck in the middle of 
  18. >a word detracts from the clarity of it's function, e.g.,
  19. >
  20. >    DUP FORTH-AND IF ...
  21. >
  22. >    I would be interested to know how others would approach this problem,
  23. >or, if you think I'm just being anal retentive and this is not a problem, I'd
  24. >like to hear your views on that too.
  25.  
  26. well if it means that much to you what you might do is create a word that
  27. overrides the vocabulary search order for just that following word.  It would
  28. be somewhat specific for which ever version of forth you were using and
  29. if you wanted to use it to execute immediate words it would be unnecessarily
  30. complex.  If I recollect my FIG-Forth it would go something like this:
  31.  
  32. : FORTH: ( _)   CONTEXT @  [COMPILE] FORTH   '  CFA ,  CONTEXT ! ;
  33.    IMMEDIATE
  34.  
  35. I used [COMPILE] FORTH because some implimentations have made
  36. vocabularies IMMEDIATE.  It should work for those that don't though.
  37.  
  38. Now your example would be:
  39.  
  40.     DUP  FORTH: AND  IF ...
  41.  
  42.  
  43. Hope this helps,
  44.    Kevin Haddock
  45.    fish@cscihp.ecst.csuchico.edu
  46.  
  47.  
  48. --------
  49. Hackers do it with fewer instructions!
  50.  
  51. Newsgroups: comp.lang.forth
  52. Subject: Re: Question: programming practice
  53. Summary: 
  54. Expires: 
  55. References: <BzMquL.2CE@news.iastate.edu>
  56. Sender: 
  57. Followup-To: 
  58. Distribution: 
  59. Organization: California State University, Chico
  60. Keywords: 
  61.  
  62. In article <BzMquL.2CE@news.iastate.edu> bible@iastate.edu (Anthony E Bible) writes:
  63. >
  64. >    I am writing a little program in which it is most reasonable to name a
  65. >couple of the words AND and IMMEDIATE.  These are already defined, of course,
  66. >and some of the later words use the new AND while others use the FORTH AND.  In
  67. >order to distinguish between the two I either have to switch the current
  68. >vocabulary temporarily to FORTH or I have to define a different word to
  69. >distinguish between the two.  I opted to define FORTH-AND to point to FORTH's
  70. >AND so I could use the "clean" name for my program.  I don't much care for this
  71. >either, but having a "bunch" of vocabulary bookkeeping stuck in the middle of 
  72. >a word detracts from the clarity of it's function, e.g.,
  73. >
  74. >    DUP FORTH-AND IF ...
  75. >
  76. >versus
  77. >
  78. >
  79. >
  80. >Hmmm.  Maybe I don't need DEFINITIONS in there.  Anyway, you see my point I 
  81. >hope.  I haven't written any IMMEDIATE words yet, but I may end up having some,
  82. >and I can scarcely immagine using more than one word for that.
  83. >
  84. >
  85. >    I would be interested to know how others would approach this problem,
  86. >or, if you think I'm just being anal retentive and this is not a problem, I'd
  87. >like to hear your views on that too.
  88. >
  89. >Thanks.
  90. >
  91. >Regards,
  92. >tony
  93.  
  94. well if it means that much to you what you might do is create a word that
  95. overrides the vocabulary search order for just that following word.  It would
  96. be somewhat specific for which ever version of forth you were using and
  97. if you wanted to use it to execute immediate words it would be unnecessarily
  98. complex.  If I recollect my FIG-Forth it would go something like this:
  99.  
  100. : FORTH: ( _)   CONTEXT @  [COMPILE] FORTH   '  CFA ,  CONTEXT ! ;
  101.    IMMEDIATE
  102.  
  103. I used [COMPILE] FORTH because some implimentations have made
  104. vocabularies IMMEDIATE.  It should work for those that don't though.
  105.  
  106. Now your example would be:
  107.  
  108.     DUP  FORTH: AND  IF ...
  109.  
  110.  
  111. Hope this helps,
  112.    Kevin Haddock
  113.    fish@cscihp.ecst.csuchico.edu
  114.  
  115.  
  116. --------
  117. Hackers do it with fewer instructions!
  118.