RetroForum Welcome, Guest. Please login or register.
September 09, 2010, 11:01:46 PM
Home Help Search Calendar Login Register

RetroForth Discussion  |  Older Boards  |  Development  |  Topic: A change in the internals « previous next »
Pages: 1 Go Down Print
Author Topic: A change in the internals  (Read 1266 times)
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
A change in the internals
« on: October 09, 2005, 06:30:41 PM »

I've made a few significant changes to the internal design of RetroForth over the last few days. Those who follow the blog ("news" link in the header) will already be aware of these, but many will not.

The dictionary header is now:

Code:
dd link_to_previous_entry
dd address_of_word
dd class_of_word
db length_of_name
db '....name....'

The change here is the addition of dd class_of_word. More on this in a minute.

The second change: As a result of the change to the dictionary format, the separate macro dictionary has been removed.

The third change: All colon definitions are now vectored. (This will mean little to most people, suffice it to say that in 99% of cases no code needs to be altered as a result of this)

The fourth change: the interactive interpreter is now decoupled from the rest of the core. Again, this won't matter to most people, except those writing new ports.

Back to the dictionary changes. Instead of two dictionaries, we now make use of word classes, a concept I first learned of from Helmar. Three classes of words are provided in the basic system:

forth (normal forth words, work as before)
macro (compiler macros, work as before)
self (new class, always called, never compiled. Can do separate actions for compiling and interpreting by checking the 'state' of the environment)

You can define new classes as well (an 'inline' class follows at the end of this post). Changing the class of an existing word is possible, and supported directly. All in all, it's really a nice set of changes. Much redundancy in the core has been eliminated, and new options for optimization are now possible. If anyone has questions, please ask them here and I'll try to explain things better.


And now for the example of an inline class:

Code:
loc:
  : copy repeat dup c@ dup $c3 =if 2drop ;; then 1, 1+ again ;
  : inline state @ if copy ;; then execute ;
  :: ['] inline class ! ;
;loc alias inline

| Now let's make some definitions inline themselves when
| used in a definition.
|
| Definitions that call other words can't be inlined with the
| above code.

inline
reclass: dup
reclass: drop
reclass: swap
reclass: 1+
reclass: 1-
reclass: true
reclass: false
reclass: @
reclass: !
reclass: w!
reclass: c!
reclass: -
reclass: nip
reclass: >>
reclass: <<
forth
Logged
Pages: 1 Go Up Print 
RetroForth Discussion  |  Older Boards  |  Development  |  Topic: A change in the internals « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!