strong/weak typing and pointers

Christophe Cavalaria chris.cavalaria at free.fr
Thu Nov 4 17:27:09 EST 2004


Michael Hobbs wrote:

> Steven Bethard <steven.bethard at gmail.com> wrote:
>> My point here is that I think in most code, even when people do a bunch
>> of bit-twiddling, they have a single underlying structure in mind, and
>> therefore you see them treat the bits as one of two things: (1) The
>> sequence of bits, i.e.
>> the untyped memory block, or (2) the intended structure.  IMHO, an
>> example of taking advantage of weak-typing would be a case where you
>> treat the bits as three different things: the sequence of bits, and two
>> (mutually exclusive) intended structures.
> 
> One word: union
Note that in the C standard, writing to part A of an union and reading from
part B is UB : undefined behavior and so it should *not* be used.



More information about the Python-list mailing list