home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!gatech!pitt!willett!ForthNet
- From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie)
- Newsgroups: comp.lang.forth
- Subject: Data types
- Message-ID: <4041.UUL1.3#5129@willett.pgh.pa.us>
- Date: 4 Sep 92 11:20:52 GMT
- Organization: EIEI-U
- Lines: 40
-
- Category 10, Topic 29
- Message 17 Fri Sep 04, 1992
- B.DUNN5 [Brian] at 02:19 EDT
-
- I would like to make a portable structure/array package. In order to hide
- the names of the fields of a structure, a structure definition would declare a
- vocabulary and place the field names inside that. Instances of that structure
- would have to activate that vocabulary at compile time, and pointers could be
- type cast by explicitly naming that vocabulary in the source code to cause the
- field names to become visible.
-
- If a structure is a field inside another structure, the source could be:
- ( ... define some fields ... )
- name1 structure: name2 \ name1 is previous struct, name2 is fieldname
- ( ... define more fields ... )
-
- When the structure NAME1 was previously defined, its final size was stored
- somewhere in the data area for NAME1. On a typical Forth-83 system this might
- be just after the threads and voc-link in the vocabulary which is called
- NAME1. Thus, NAME1 would be an immediate vocabulary with one extra cell of
- information in its data area.
-
- At compile time, NAME1 would cause the vocabulary associated with its
- structure to become active. STRUCTURE: would have to look at the context
- vocabulary and compute from that the location where NAME1 stored its final
- length, so that STRUCTURE: knows how large the field NAME2 must be.
-
- With ANS-Forth:
-
- 1) Is there a portable way to create the functionality where NAME1 activates a
- wordlist and also has a known location to store its length?
-
- 2) Can other words take the top wordlist and compute (portably) where the
- length is stored?
-
- -----
- This message came from GEnie via willett. You *cannot* reply to the author
- using e-mail. Please post a follow-up article, or use any instructions
- the author may have included (USMail addresses, telephone #, etc.).
- Report problems to: dwp@willett.pgh.pa.us
-