stephenXXX@[EMAIL PROTECTED]
(Stephen Pelc) writes:
>Mitch Bradley wrote the following about structure alignment:
....
>Since I do much more (b) than (a), I prefer a structure definition
>basis
>that is fundamentally unaligned. It is much easier to add alignment
>than to undo it."
He also wrote that he liked (the semantics of) Gforth's FIELD, which
does sup****t, but not enforce alignment.
In particular, if you want unaligned fields, the only cost is that you
have to write an additional "1" per field. I would like to see a
rationale by you why you consider that worse than your proposal. The
only rationale I have seen by you is that you have had problems with
C; but Gforth is not C, and Gforth's FIELD does something different
than C; in particular:
|field ( align1 offset1 align size "name" - align2 offset2 )
|
|Create a field NAME with offset OFFSET1, and the type given by ALIGN
|SIZE. OFFSET2 is the offset of the next field, and ALIGN2 is the
|alignment of all fields.
If you want an unaligned 4-byte field, you write
1 4 field <name>
[Of course the name would have to be changed, and the specification
adjusted to a more standard-do***ent style]
>The recommended field type definers are:
> CFIELD: 1 character
> IFIELD: native integer (single cell)
> FFIELD: native float
Fill in the blank:
C@[EMAIL PROTECTED]
F@[EMAIL PROTECTED]
@[EMAIL PROTECTED]
C! F! !
CFIELD: FFIELD:
Calling that word that fills the blank IFIELD: would be a severe
mistake, in breaking the usual Forth conventions and making both this
word hard to remember as well as all others that deal with single
cells. Ok, so this is would not be the first time that this mistake
is made (the order of locals in LOCALS| comes to mind), but we should
not repeat this mistake.
I see two possible solutions:
1) Call the single-cell word FIELD: and the general word differently.
2) Only propose the general FIELD:, but not the type-specific words.
fup2 clf.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2006: http://www.complang.tuwien.ac.at/anton/euroforth2006/


|