[sdiy] Pointers in C

Neil Johnson neil.johnson97 at ntlworld.com
Wed Jan 4 11:21:15 CET 2012


Magnus,

> I disagree here Neil, they are very similar but different from structs. They
> are like structs, where the members don't get offsets, but the complete
> storage will fit all members just like structs, just that they don't all fit
> in at the same time individually.

In the context of the C type system they are completely different:
- the semantics are completely different: a struct is an aggregate
data type (together with arrays), a union is not, and is C's closest
equivalent of a multi-ported type (although not exactly).
- a struct can hold multiple objects at the same time; a union holds
exactly one at any given moment together with some special rules that
are specific to unions and have nothing even vaguely similar for
structs.

> They are not completely different, the if-statement is completely different
> from the union. They are different, but not completely different, as there
> is too much similarities. Compare other different but not completely
> different constructs such as the while-statement and the do-while-statement.

Now you're being silly.  The if-statement is from an altogether
different part of the language (statements vs types).  But, yes, the
while-statement and the do-while-statement are related: they are both
looping statements (or "iteration statements" in the language of the
spec).

For those of you lost by this, let me summarise:

Neil said: an orange is completely different from an apple (although
both are in the category "fruit").

Magnus said: no, an orange is only different from an apple; an orange
is completely different from a brick.

I promise my next post will be more closely related to synthesizers!

Cheers,
Neil
-- 
http://www.njohnson.co.uk



More information about the Synth-diy mailing list