union access

C

Chris Dollin

Dan said:
Which is precisely what makes unions and structures completely different
things, despite any *superficial* similarities.

Just because there's an important difference doesn't make them
"completely different".

If structures and unions are "completely different", what are you
left with to express, say, the difference between ints and structures?
Unions and functions? Types and statements?
And of course they're syntactically almost identical.

Which means exactly zilch. if and while are also syntactically almost
identical, yet they are still completely different things.

You must have some awsomely picky notion of sameness, then, since
both if [1] and while are semantically very similar things -

You must have some awsomely lax notion of sameness, if the if and while
statements look semantically very similar to you. To me, the only
statements semantically close to while are do and for.

I don't weight the presence or absence of iteration as highly as you
do, and I rate the similarity of treatment of subcomponents more than
you do. Why is why I pointed out you could improve your argument by
picking `switch` instead of `if`.
Then again, a wheel mouse and a wheelbarrow might be semantically very
similar things to you...

They're much more similar than, say, a wheel mouse and a photon, or
a wheelbarrow and _Twelveth Night_, or a house and being arrested,
or a headache and a telephone.

[Just because I'm different from you doesn't mean I'm *completely*
different from you.]
 
R

Richard Bos

Mabden said:
Well, that _was_ actually the argument. Someone had a problem with Dan
Pop saying they were "completely different" and off it went. I think
they are completely different in use and concept, if not in declaration
or whatever the Standard Readers suggest.

And they're _not_ completely different. Neither are they completely
equal. They are quite similar to some degree, and quite dissimilar in
other aspects. Such a subtle nuance may be too difficult to grasp for
black-and-white minds like yours and Dan Pop's, but that doesn't make it
any less valid.
Well, I was asking a question, not posting "facts".

You were _stating_, not asking but claiming outright, that
Structs and unions have a similar definition, so the Standards Whores
think they are the same, but in fact if they were that similar you
could, for instance make a union array.

And that is a nonsensical statement, as well as quite a stupid kind of
insult.
And since they're not being paid, should I just say Standards Sluts? ;-)

You, sir, are an imbecile.

Richard
 
D

Dan Pop

In said:
[Just because I'm different from you doesn't mean I'm *completely*
different from you.]

OK, name two completely different things and explain why they are
completely different. I'm sure someone else would disagree ;-)

Dan
 
D

Dan Pop

In said:
This whole argument is about a claim that structs and unions are
"completely different". They are neither identical nor completely
different; they're similar in some ways, different in others.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is true for *any* pair of things. By your logic, there are no two
things that are completely different.

By my logic, the huge semantic differences between unions and structures
(structure types are aggregate types, union types aren't) make them
completely different things.

Dan
 
C

Chris Dollin

Dan said:
In <[email protected]> Chris Dollin
[Just because I'm different from you doesn't mean I'm *completely*
different from you.]

OK, name two completely different things and explain why they are
completely different. I'm sure someone else would disagree ;-)

Since they would share the property "named by Chris as an example",
the act of producing them would make them less different than they
were before.

Since you're pushing this side-track, am I to assume you acknowledge
that structs and unions are not *completely* different? I'm willing
to limit the kinds of properties under discussion to those relevant
to programming languages - "completely" comes with context, after
all.
 
D

Dan Pop

In said:
Since you're pushing this side-track, am I to assume you acknowledge
that structs and unions are not *completely* different?

Nope. Merely pointing out that is possible to define "completely
different" in such a way as to make it devoid of any practical meaning.
I'm willing
to limit the kinds of properties under discussion to those relevant
to programming languages - "completely" comes with context, after
all.

And I have *explicitly* limited the relevant properties to the semantic
ones. Syntactic similarities have no relevance in context.

Dan
 
A

Alex Monjushko

Dan Pop said:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is true for *any* pair of things. By your logic, there are no two
things that are completely different.
By my logic, the huge semantic differences between unions and structures
(structure types are aggregate types, union types aren't) make them
completely different things.

The degree of similarity between two objects is determined by the
set of their common attributes. As long as there are common attributes,
they can not be declared "completely different." As long as there are
different attributes, they can not be declared "exactly the same."

Furthermore, the degree of similarity between structs and unions happens
to be quite high, because they share more common attributes with each
other than with any other constructs in C. A significant semantic
difference does not render them "completely different."
 
K

Keith Thompson

In <[email protected]> Chris Dollin


Nope. Merely pointing out that is possible to define "completely
different" in such a way as to make it devoid of any practical meaning.


And I have *explicitly* limited the relevant properties to the semantic
ones. Syntactic similarities have no relevance in context.

We all know what structures are. We all (presumably) know what unions
are. The current debate about whether or not they're "completely
different" isn't about structures and unions; it's about the meaning
of the phrase "completely different". Perhaps alt.english.usage would
be a good place to have that debate, unless someone raises a point
that's actually about the C language.
 
D

Default User

Keith said:
We all know what structures are. We all (presumably) know what unions
are. The current debate about whether or not they're "completely
different" isn't about structures and unions; it's about the meaning
of the phrase "completely different". Perhaps alt.english.usage would
be a good place to have that debate, unless someone raises a point
that's actually about the C language.

alt.usage.english has much better traffic and availability.




Brian Rodenborn
 
F

Flash Gordon

Pascal is not as versatile as C. You might have to do tricks to play
games around the compiler. Perhaps you should have used a Real
language to begin with...?

Your ignorance is showing again (I know complete embedded systems
including as much of an OS as was required that are implemented in
Pascal). Variant records are no more a"trick" than unions in C. In fact,
untagged variant records have identical almost semantics, right down to
the problems with writing as one type and reading as another.

Some things are actually easier in Pascal than they are in C! However, I
choose to use C rather than Pascal when given a choice.
"more similar that functions" doesn't make sense.

So I made a typo. I would have thought that anyone could see than I
intended to say "than" rather than "that".
What I said does.
See, we are comparing "apples to oranges", so I am bound to compare
things that are dissimilar (is that a word? unsimilar?). See, I
believe unions and struct are dissimilar - even though they look the
same. Is a duck a goose? Is a zebra a mule?

To use your analogy, which things have more in common:
1) A zebra and a mule
2) A zebra and an apple.

Just to help you along I will point out that not only are zebras and
mules animals (unlike apples) with 4 legs and hoofs, both can be ridden
etc, but they also both have a common ancestor.

Then, just to help you a bit further, determining how similar two things
are is done by examining the two items to determine what characteristics
they have in common and to what degree and what aspects are different
and to what degree.

If one stick to black and white you don't need the word similar at all,
since either two things are exactly the same thing or they are different
things. So if you compare two mules you will find they are different (if
nothing else they are in different places and that is a difference)
 
P

pete

Flash Gordon wrote:
Your ignorance is showing again (I know complete embedded systems
including as much of an OS as was required that are implemented in
Pascal). Variant records are no more a"trick" than unions in C.
In fact, untagged variant records have identical almost semantics,
right down to
the problems with writing as one type and reading as another.

Here's what K&R2 says about unions:
6.8 Unions
They are analogous to variant records in Pascal.
 
C

Chris Dollin

Dan said:
In <[email protected]> Chris Dollin


Nope. Merely pointing out that is possible to define "completely
different" in such a way as to make it devoid of any practical meaning.

Certainly, but I haven't done that. You can if you like, but it will make
the discussion a bit pointless.
And I have *explicitly* limited the relevant properties to the semantic
ones. Syntactic similarities have no relevance in context.

I just wanted to seal off an exit I thought you might have been forced
to take. I'm happy for you to have thrown away the key yourself.
 
Y

Yevgen Muntyan

Alex said:
...
The degree of similarity between two objects is determined by the
set of their common attributes. As long as there are common attributes,
they can not be declared "completely different." As long as there are
different attributes, they can not be declared "exactly the same."

Yeah, please nobody tell that windows and linux or c and java are
completely different. As long as there are common attributes, they
cannot be declared "completely different".
Furthermore, the degree of similarity between structs and unions happens
to be quite high, because they share more common attributes with each
other than with any other constructs in C. A significant semantic
difference does not render them "completely different."

Yep. If you say that two things are "completely different", you better
talk to your lawyer first. And if somebody ask you what's the difference
between char and char*, you don't tell that they are different - first
explain everything you know about computer memory, blah-blah-blah, and
only after that you can make a remark (but don't insist) about semantic
difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top