[net.lang.c] Notes on the ANSI standard

mike@asgb.UUCP (10/17/84)

<>

A couple thoughts on the proposed ANSI C standard.  I'm reading from the
September 12, 1984 draft.

(1)
I too must throw in my vote against the 6 character limit for external
names.  It's time that this vestige of the 60's be thrown out.  I
think previous discussions in this newsgroup have covered the subject
adequately.


(2)
Section 4.1.3 states:

   "With one exception, a member of a union object may not be
   inspected unless the value of the object has been assigned
   using that same member."

HOLY <censored>!!  Whatever happened to overlaying values of differing
types?  One of the more handy uses of unions is overlaying bitfields
with an integer so that the bits can be twiddled individually, but the
integer can be used for block operations on all the bits.  I've also
used similar techniques for decoding bit fields of devices like a
Summagraphic Bitpad, or several mouses.

I will grant that this is not good practice for writing portable code.
But to have these practices forbidden or enforced by the compiler is
totally unreasonable, especially for a systems implementation
language!  (In implementation, enforcing this restriction seems
pretty cumbersome.)


Mike Rosenlof
Burroughs Advanced Systems Group
...hplabs!sdcrdcf!bmcg!asgb!mike

henry@utzoo.UUCP (Henry Spencer) (10/21/84)

> Section 4.1.3 states:
> 
>    "With one exception, a member of a union object may not be
>    inspected unless the value of the object has been assigned
>    using that same member."
> 
> HOLY <censored>!!  Whatever happened to overlaying values of differing
> types?  One of the more handy uses of unions is overlaying bitfields
> with an integer so that the bits can be twiddled individually, but the
> integer can be used for block operations on all the bits.  I've also
> used similar techniques for decoding bit fields of devices like a
> Summagraphic Bitpad, or several mouses.

Unions were intended as a storage-allocation-control mechanism, not as
a way to do type cheating.  The orthodox way to do the latter is casts.

Incidentally, using integers and bit operations (yes, I know it's ugly)
is probably more portable than bitfields.  Believe it or not.  Partly
because a good many compilers botch bitfields, partly because things
like the bit allocation of bitfields are very compiler-dependent.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

joemu@tekecs.UUCP (Joe Mueller) (10/30/84)

> (2)
> Section 4.1.3 states:
> 
>    "With one exception, a member of a union object may not be
>    inspected unless the value of the object has been assigned
>    using that same member."
> 
> HOLY <censored>!!  Whatever happened to overlaying values of differing
> types?  One of the more handy uses of unions is overlaying bitfields
> with an integer so that the bits can be twiddled individually, but the
> integer can be used for block operations on all the bits.  I've also
> used similar techniques for decoding bit fields of devices like a
> Summagraphic Bitpad, or several mouses.
> 
> I will grant that this is not good practice for writing portable code.
> But to have these practices forbidden or enforced by the compiler is
> totally unreasonable, especially for a systems implementation
> language!  (In implementation, enforcing this restriction seems
> pretty cumbersome.)

The problem with overlaying values of differing types to twiddle bits
is that the twiddling is VERY implementation dependent. The intent of
the committee is that the use of such practice should be discourageed
and the result of such operation is UNDEFINED. I shall take it up with
the committee to put words to that effect in the standard so that it
is not expessly forbidden.