F
Francis Moreau
Hello,
Could anybody show me some examples where composite types can be
useful ?
Thanks
Could anybody show me some examples where composite types can be
useful ?
Thanks
Let me guess: Your homework question was "Give some examples where
composite types can be useful".
Francis said:It's been a while that I haven't done any homework.
let me guess: you're trying to do some homework but you're currently
stuck. So now you're bored enough to come and doing some stupid
guesses.
Do you realize this is a place where people can come to ask questions
(about C), so your useless follow up can be applied to almost all
posts ?
Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
It's been a while that I haven't done any homework.let me guess: you're trying to do some homework but you're currently
stuck. So now you're bored enough to come and doing some stupid
guesses.Do you realize this is a place where people can come to ask questions
(about C), so your useless follow up can be applied to almost all
posts ?Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
So what's difficult to understand about the usefullness of something like:
struct employee {
int empnum;
struct employee *boss;
char firstname[16];
char lastname[16];
long long salary; /**/
} employee;
Francis Moreau said:Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
Francis said:Francis said:On 5 juin, 23:41, "christian.bau" <[email protected]>
wrote:
Could anybody show me some examples where composite types can be
useful ?Let me guess: Your homework question was "Give some examples where
composite types can be useful".It's been a while that I haven't done any homework.let me guess: you're trying to do some homework but you're currently
stuck. So now you're bored enough to come and doing some stupid
guesses.Do you realize this is a place where people can come to ask
questions (about C), so your useless follow up can be applied to
almost all posts ?Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
So what's difficult to understand about the usefullness of something
like:
struct employee {
int empnum;
struct employee *boss;
char firstname[16];
char lastname[16];
long long salary; /**/
} employee;
I'm taking about what is defined in 6.2.7.p3.
6.2.7.p5 gives an example, doesn't this make it more clearI don't see your point...
Ben Bacarisse said:I doubt that there are any. The definition is there to serve a
purpose withing the language standard. Since the purpose is to
defined the effective type in cases where there is some potential
ambiguity, I would argue that a program that replies on the definition
should be re-written so that it does not!
It is important when old- and new-style function declarations are
mixed, but that is a sort of transitional style of C that has all but
disappeared.
Francis said:It's been a while that I haven't done any homework.
let me guess: you're trying to do some homework but you're currently
stuck. So now you're bored enough to come and doing some stupid
guesses.
Do you realize this is a place where people can come to ask questions
(about C), so your useless follow up can be applied to almost all
posts ?
Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
So what's difficult to understand about the usefullness of something like:
struct employee {
int empnum;
struct employee *boss;
char firstname[16];
char lastname[16];
long long salary; /**/
} employee;
Joachim Schmitz said:Francis said:On 6 juin, 14:55, "Joachim Schmitz" <[email protected]>
wrote: [...]Could anybody show me some examples where composite types can be
useful ? [...]
So what's difficult to understand about the usefullness of something
like:
struct employee { [...]
} employee;
I'm taking about what is defined in 6.2.7.p3.
Your question was (and this is quoted above too, repeated here for clarity:
$ Subject: What are composite type used for ?
$ Could anybody show me some examples where composite types can be useful?
So how should anybody have guessed you'd really talking about 6.2.7.p3?
6.2.7.p5 gives an example, doesn't this make it more clear
Tim Rentsch said:Ben Bacarisse said:I doubt that there are any. The definition is there to serve a
purpose withing the language standard. Since the purpose is to
defined the effective type in cases where there is some potential
ambiguity, I would argue that a program that replies on the definition
should be re-written so that it does not!
It is important when old- and new-style function declarations are
mixed, but that is a sort of transitional style of C that has all but
disappeared.
Isn't it also relevant when combining complete types and
incomplete types? eg,
extern int a[];
...
int a[20] = {0};
Surely you don't mean to suggest that all such code be
re-written.
Barry said:Francis said:On 5 juin, 23:41, "christian.bau" <[email protected]>
wrote:
Hello,
Could anybody show me some examples where composite types can be
useful ?
Let me guess: Your homework question was "Give some examples where
composite types can be useful".
It's been a while that I haven't done any homework.
let me guess: you're trying to do some homework but you're currently
stuck. So now you're bored enough to come and doing some stupid
guesses.
Do you realize this is a place where people can come to ask
questions (about C), so your useless follow up can be applied to
almost all posts ?
Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.
So what's difficult to understand about the usefullness of something
like:
struct employee {
int empnum;
struct employee *boss;
char firstname[16];
char lastname[16];
long long salary; /**/
} employee;
That is not a composite. (It is an aggregate but that is a different
discussion.)
Joachim Schmitz said:Francis said:On 6 juin, 14:55, "Joachim Schmitz" <[email protected]>
wrote: [...]
Could anybody show me some examples where composite types can be
useful ? [...]
So what's difficult to understand about the usefullness of something
like:
struct employee { [...]
} employee;
I'm taking about what is defined in 6.2.7.p3.Your question was (and this is quoted above too, repeated here for clarity:
$ Subject: What are composite type used for ?
$ Could anybody show me some examples where composite types can be useful?So how should anybody have guessed you'd really talking about 6.2.7.p3?
Because 6.2.7p3 is where the term "composite type" is defined (it's in
italics there).
I admit that I didn't realize that myself; I confused "composite
types" with "aggregate types", which are defined in 6.2.5p21. Until
today, I hadn't even been aware of the concept.
Francis probably should have cited 6.2.7p3 in his original question,
and the rest of us (myself included) shouldn't have jumped to
conclusions.
6.2.7.p5 gives an example, doesn't this make it more clear
It shows an example of a composite type; it doesn't say much about why
it's useful. And in that particular case, I'd say it isn't; both
declarations should have used the more specific type in the first
place. I think it's more about declarations involving old-style
function declarations that a compiler is required to accept than about
anything a programmer should really be using. (Though somebody
elsethread presented a more reasonable example.)
--
Keith Thompson (The_Other_Keith) (e-mail address removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
I doubt that there are any.
The definition is there to serve a
purpose withing the language standard. Since the purpose is to
defined the effective type in cases where there is some potential
ambiguity, I would argue that a program that replies on the definition
should be re-written so that it does not!
It is important when old- and new-style function declarations are
mixed, but that is a sort of transitional style of C that has all but
disappeared.
I note that my typo density is as
high as ever; congratulations are due for being able to extract
meaning from what I wrote.
I doubt that there are any. The definition is there to serve a
purpose withing the language standard. Since the purpose is to
defined the effective type in cases where there is some potential
ambiguity, I would argue that a program that replies on the definition
should be re-written so that it does not!It is important when old- and new-style function declarations are
mixed, but that is a sort of transitional style of C that has all but
disappeared.
Isn't it also relevant when combining complete types and
incomplete types? eg,
extern int a[];
...
int a[20] = {0};
Surely you don't mean to suggest that all such code be
re-written.
Well, I did a quick Google search on "compostite type C" and ended up with
http://en.wikipedia.org/wiki/Composite_type:
In computer science, composite data types are data types which can be
constructed in a program using its programming language's primitive data
types and other composite types.
And then talks about structs in C and classes in C++.
Bad luck that the C standard calls them differently...
Barry Schwarz said:Strange. I clicked on your link above and was told Wikipedia does not
have an article with this name.
Barry Schwarz wrote:
) On Sun, 7 Jun 2009 10:38:38 +0200, "Joachim Schmitz"
)> <snip>
)>http://en.wikipedia.org/wiki/Composite_type:
)
) Strange. I clicked on your link above and was told Wikipedia does not
) have an article with this name.
There's nothing strange about that.
Your news reading software simply made a wrong guess.
Barry Schwarz said:What kind of guessing is involved when the url is completely
specified? My browser contained the same url so it is obvious my
newsreader didn't guess or change anything.
As noted else-thread, there is a typo in the url in the original post.
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.