What are composite type used for ?

F

Francis Moreau

Hello,

Could anybody show me some examples where composite types can be
useful ?

Thanks
 
F

Francis Moreau

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.
 
J

Joachim Schmitz

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; /* :cool: */
} employee;

Bye, Jojo
 
F

Francis Moreau

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; /* :cool: */

} employee;

I'm taking about what is defined in 6.2.7.p3.

I don't see your point...
 
B

Ben Bacarisse

Francis Moreau said:
Just to clarify, I find composite type obscure enough that I can't
find any usefull use cases.

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.
 
J

Joachim Schmitz

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; /* :cool: */

} 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?
I don't see your point...
6.2.7.p5 gives an example, doesn't this make it more clear

Bye, Jojo
 
T

Tim Rentsch

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.
 
B

Barry Schwarz

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; /* :cool: */
} employee;

That is not a composite. (It is an aggregate but that is a different
discussion.)
 
K

Keith Thompson

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.)
 
B

Ben Bacarisse

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.

I had forgotten about that case. I note that my typo density is as
high as ever; congratulations are due for being able to extract
meaning from what I wrote.
 
J

Joachim Schmitz

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; /* :cool: */
} employee;

That is not a composite. (It is an aggregate but that is a different
discussion.)

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...

Bye, Jojo
 
F

Francis Moreau

Hello Keith,

Thanks for taking time to answering to Joachim

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"
 
F

Francis Moreau

Hello,

I doubt that there are any.

That somehow conforting me.
 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 see.

Thanks for your _usefull_ follow up.
 
F

Francis Moreau

 I note that my typo density is as
high as ever; congratulations are due for being able to extract
meaning from what I wrote.

Even with some typos, your answer is _far_ more interesting than some
other ones ;)
 
F

Francis Moreau

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.

That's a good point.

But the obscure usage was more about function declaration, sorry for
not specifying this.
 
B

Barry Schwarz

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...

Strange. I clicked on your link above and was told Wikipedia does not
have an article with this name.
 
W

Willem

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.


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
 
B

Barry Schwarz

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.

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.
 
K

Keith Thompson

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.

No, I don't think it was a typo. The ':' was intended as English
punctuation, not as part of the URL. Barry's newsreader apparently
wasn't able to figure that out. (Not that it necessarily should have;
it's genuinely ambiguous.
 

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

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top