What are composite type used for ?

S

Sjouke Burry

Keith said:
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.
I found two pages: one with and one without the ":"
quite different pages.
xp sp2 TB 2.0.0.21
 
B

Barry Schwarz

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.

What type of standard English punctuation is it when the text that
follows the colon starts a new paragraph and addresses a completely
different issue?
 
K

Keith Thompson

Barry Schwarz said:
What type of standard English punctuation is it when the text that
follows the colon starts a new paragraph and addresses a completely
different issue?

Did you read the same article I did? Here's what Joachim Schmitz
posted:

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

The URL (followed by a colon) was followed immediately by a quotation
from the web page.
 
G

Guest

It's been a while that I haven't done any homework.

"homework" on this context means "a question that is only meaningful
in an educational context". This might be a formal course of
instruction,
a training course or reading a book for self eduction. Another one
might
be a job interview.

People don't wake up in the night screaming "for cthulu's sake what
*is* a composite type useful FOR!!!!!".

It doesn't usually come up in casual converstaions by the coffee
machine
either.

So what prompted you to ask the question? What do you think a
composite
type is?
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.

what is a composite type? I'm an experienced C programmer and I don't
casually use the term. A struct?
 
J

James Kuyper

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

what is a composite type? I'm an experienced C programmer and I don't
casually use the term. A struct?
6.2.7:

> 3. A composite type can be constructed from two types that are
> compatible; it is a type that is compatible with both of the two
> types and satisfies the following conditions:
>
> — If one type is an array of known constant size, the composite
> type is an array of that size; otherwise, if one type is a
> variable length array, the composite type is that type.
>
> — If only one type is a function type with a parameter type list
> (a function prototype), the composite type is a function
> prototype with the parameter type list.
>
> — If both types are function types with parameter type lists, the
> type of each parameter in the composite parameter type list is
> the composite type of the corresponding parameters.
>
> These rules apply recursively to the types from which the two types
> are derived.
>
> 4 For an identifier with internal or external linkage declared in a
> scope in which a prior declaration of that identifier is visible,47)
> if the prior declaration specifies internal or external linkage, the
> type of the identifier at the later declaration becomes the
> composite type.
>
> 5 EXAMPLE Given the following two file scope declarations:
>
> int f(int (*)(), double (*)[3]);
> int f(int (*)(char *), double (*)[]);
>
> The resulting composite type for the function is:
>
> int f(int (*)(char *), double (*)[3]);

> 47) As specified in 6.2.1, the later declaration might hide the prior
> declaration.


The first item listed in paragraph 3 allows you make an array externally
available while restricting knowledge of its length, as follows:

foo.h:
======
extern int foo[];

foo.c:
======
#include "foo.h"
int foo[4096];

bar.c:
======
#include "foo.h"
int getfoo(int i) { return foo; }

The second and third parts of paragraph 3 allow prototyped and
unprototyped function declarations for the same function to co-exist.
with the prototyped declaration essentially overriding the unprototyped one.
 
J

Joachim Schmitz

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

Strange indceed, because it works just fine for me
 
J

Joachim Schmitz

Richard said:
Keith Thompson said:


Hence the note in the appendix of RFC1738:

"In addition, there are many occasions when URLs are included in
other kinds of text; examples include electronic mail, USENET news
messages, or printed on paper. In such cases, it is convenient to
have a separate syntactic wrapper that delimits the URL and
separates it from the rest of the text, and in particular from
punctuation marks that might be mistaken for part of the URL. For
this purpose, is recommended that angle brackets ("<" and ">"),
along with the prefix "URL:", be used to delimit the boundaries of
the URL. This wrapper does not form part of the URL and should not
be used in contexts in which delimiters are already specified."

Thus, the OP could have written:

<http://en.wikipedia.org/wiki/Composite_type>:

unambiguously.

OK, I hope I'll remember this for next time
 
R

Richard Bos

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

I don't think composite types are something you _use_, as such. They're
a description of how the compiler should behave if you use two different
but compatible declarations together, but you can't define a function
"of composite type".

Richard
 

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
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top