Topic: Proposal: enum flag extension or bit-field syntax extensions
Author: max.teneyck.woodbury@verizon.net ("Max T. Woodbury")
Date: Wed, 11 May 2005 20:59:20 GMT Raw View
Christoph Seifert wrote:
>
> thank you very much for your comment!
>
> I think my statement might have been a bit confusing.
Not so much confusing as incomplete. A specific example
or two that compared to 'old way' and the 'new way' would
probably make things clearer.
> I still think, that an implementation as in the standard
> library with enum, declarations of variables and declaration
> of bitwise operators is akward at best and lengthy at the
> very least.
Yep, but I don't think it will work as a library item. I
get the impression that this is a language issue. Adding
keywords generally is.
> ...
>
> Your proposal aims at the portability of bitfields for
> use with hardware interfaces. This I think is a different,
> though very important field.
Hmm. I think I failed to make something clear. The hardware
interface requirements are more restrictive than the information
packing requirements and thus drive the specifications. However
both sets of needs should be addressed.
----------
I've been thinking about what I proposed and think at least two
additions are called for.
1) With the understanding that the names of the 'special members'
are only suggestions, the value of (1 << field.bit) should also
exist and could be called '.lsb'.
2) There should be a way to allocate all the remaining bits in a
store without knowing exactly how many bits that is. The
syntax ': ...' might be viable.
There is also the type safety issue. Bitwise operations on a
store associated with bit-fields should be restricted to
expressions that must include 'special members' values from
those bit-fields in appropriate contexts. In effect each such
store should have restrictions similar to those associated with
a user defined type. Wording this properly could be difficult.
max@mtew.isa-geek.net
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]