Re: Newbie Question: dictionary organization?



Op 11 Jul 2006 14:09:18 -0700 schreef Jean-François Michaud:

Paul Smith wrote:
Especially for microcontroller, I liked to use this header structure:
dw len+flags (misc flags, like precedence, if applicable, and name length)
dw name (aligned word name string)
dw body (pointing first address of word "body", may be cfa)

headers and bodies are separated. headers sit in consecutive address, therefore no link
to next header. getting to the next header is done by adding aligned name length to address
of current word. a new header is added before the last word, for searching through headers
in the order last-to-first. as result, headers are added from higher to lower addresses.

This is quite the interresting idea. I had never thought of that, but
it makes alot of sense. I might reimplement my Forth to take advantage
of this feature. Shave off a few Ks of code ;-) and gain some
flexibility.

bodies do not link back to headers. there is no need to, and this facilitates moving headers
around, and/or using a different organization, for faster searching for example. in the few cases
that i need to find header from body, i simply search for the header with matching body address.
This is relatively slow, but hardly ever used - if so, mostly interactively, for debugging and such.
Being able to get rid of NFA and LFA is more than worth this minor slowdown, IMHO. Consider that
headers are relocatable, without requiring any relinking, or offset calculation. Just move them
around, and update contents of LAST or the like.
I never do assume specific header- or body structure for translating between header/body addresses.
In combination with a deferred FIND, this allows me do change the header layout or organization on
the fly, runtime. or, to get rid of headers completely, freeing the space in EEPROM or Flash, if
desired. Not seperating headers from bodies will make this an awkward operation, if possible at all
(or wasting lots of space by the gaps the headers leave you).

Thanks much for the idea.

Regards
Jean-Francois Michaud

You might have a look how eforth is implemented.
The dictionary (bodies) are allocate upwards (of course)
but the headers downwards from the end of memory.

--
Coos

CHForth, 16 bit DOS applications
http://home.hccnet.nl/j.j.haak/forth.html
.



Relevant Pages

  • Re: Newbie Question: dictionary organization?
    ... dw name (aligned word name string) ... headers and bodies are separated. ... around, and/or using a different organization, for faster searching for example. ... Being able to get rid of NFA and LFA is more than worth this minor slowdown, ...
    (comp.lang.forth)
  • Re: Nettle and UTF-8 support
    ... applications - WP, E-mail, News... ... look after, not individual applications. ... such a menu superfluous, but as things stand, for Latin 2 ... e-mail I need to edit the raw e-mail headers from ...
    (comp.sys.acorn.networking)
  • how do I change the language of the headers?
    ... I installed a version of Microsoft Office Spanish version and now I would ... like to change the headers in the applications to English. ...
    (microsoft.public.office.misc)
  • Re: Newbie Question: dictionary organization?
    ... I liked to use this header structure: ... dw name (aligned word name string) ... headers and bodies are separated. ... around, and/or using a different organization, for faster searching for example. ...
    (comp.lang.forth)
  • Re: why still use C?
    ... >+ On essentially any platform there is a unique standard API ... >+ readily used from C applications. ... >Is it feasible to interpose a proxy library whose headers are ...
    (comp.lang.c)