Hallo Martin,
Du schriebst am Thu, 7 Nov 2013 07:10:56 +0100:
> > BTW, "float" sounds awfully C-ish to me. No "real"s any more, really?
> >
> Because there could be a "complex" datatype which has two "float" fields.
Oh, I see, you think of the real/imaginary components. Indeed, that mighht
be distracting to the user, although the "real" _type_ and the _fieldname_
"real" are very different things to the compiler.
> > You might consider to have a look at FORTRAN's type system, which
> > provides a convenient notation for specifying the size of a variable or
> > type. And its advantage is that it's _not_ restricted in advance.
> >
> I do more like the <min>..<max> notation.
This doesn't really define storage requirements directly, which I supposed
was your goal. And it makes for a very clumsy notation for bitfields, that
you mentioned you'd like to support also. E.g.:
Suppose there's some part having a 16 bit register that's subdivided into 5
fields, bits 0 through 6, 7...8, 9...13, 14 and 15 (the latter are 1-bit
fields, of course).
Your construct might then look like:
Register = RECORD
Field_1: 0..127;
Field_2: 0..3;
Field_3: 0..31;
Field_4: 0..1;
Field_5: 0..1;
END;
An equivalent C struct would look like this:
struct Register = {
int Field_1: 7,
int Field_2: 2,
int Field_3: 5,
int Field_4: 1,
int Field_5: 1,
};
A common notation used by hardware technicians, looks somewhat similar to
C's notation:
Register = (
Field_1: (0:6);
Field_2: (7:8);
Field_3: (9:13);
Field_4: (14:14);
Field_5: (15:15);
);
or something similar.
The subrange method even might allow ranges of "non-binary" size, i.e.
such that don't use the full range of values a given number of bits can
represent, making it even more difficult to recognize the required number
of bits for a field.
You might specify a data structure taking the same area as above like this:
Register = RECORD
Field_1: 0..77;
Field_2: 1..3;
Field_3: 5..25;
Field_4: 111..112;
Field_5: -2..-1;
END;
(where I assumed that you would allow for negative range limits also.)
BTW, as these are real subranges, what about limit checking?
Although this approach certainly is the most flexible, it might be
considered as a rather obscure notation, requiring quite an amount of
decoding to assess the real size of the data.
This much for your consideration, the final decision is yours, of course.
--
--
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk