test(void *data) vs test(void &data)

A

Arivald

W dniu 2011-06-19 10:03, Stephen Sprunk pisze:
& is not a valid type specifier in C, period.

It might or might not be valid in C++, but since you haven't
cross-posted this to a C++ newsgroup, responding to that would be off-topic.

C and C++ are different languages. There is no language called "C/C++".

Even in C++ You can't have untyped reference (reference to void).

So case 2 will never compile in C or C++.
 
J

jacob navia

Le 21/06/11 15:59, Arivald a écrit :
C may also benefit from non-NULL property of references.

Yes!

That is why the lcc-win C compiler implements references.
 
K

Keith Thompson

Arivald said:
W dniu 2011-06-20 20:51, Stephen Sprunk pisze:
On 20-Jun-11 11:17, Skybuck Flying wrote: [...]
1. Pascal has call by value and call by reference.

No, there is no references in pascal. There are constructs which works
like C++ reference, but under many different names.

He didn't say Pascal has references; he said Pascal has call by
reference. Which it does; that's what "var" parameters are.
For example, parameters passed using "var" (always) and "const"
(possibly, if it is faster than non-reference pasing) are passed by
reference. Specifically only pointer to variable is passed.
Sometimes this passing methods are called "passing by reference",
although it is not exactly correct.

I think it is, given the usual (not necessarily language-specific)
meaning of the phrase "call by reference" or, as I prefer to call it,
"pass by reference".
Objects (TObject descandants), string, Variant and other automated types
are references itself. They are passed by value (if without "var" or
"const"), but because they are references, it effectively works like
passing by reference.

You seem to be talking about some dialect of Pascal, not standard
Pascal itself.
Yes and no.
Passed pointer is value, but it is also reference to other value.

The C language only has pass by value. Features of the language can
be used to implement (or, if you prefer, emulate) pass by reference.

[...]
 
S

Skybuck Flying

"Stephen Sprunk" wrote in message
Call by reference in pascal has huge adventages compared to C.

"
Only for those, such as you, who don't really understand C.
"

Nope, no asterixes needed = no extra bugs ! ;) =D
You accidently delete one little asterix somewhere and you have a crisis
;) :)

"
No, if you accidentally delete one little asterisk someone, the compiler
warns you of a type mismatch, and you fix that and move on.
"

Perhaps, perhaps not, totally depends on the situation.

Bye,
Skybuck.
 
S

Skybuck Flying

"Mark Storkamp" wrote in message

Skybuck Flying said:
Please stop the nonsense.

Call by reference in pascal has huge adventages compared to C.

You accidently delete one little asterix somewhere and you have a crisis
;)
:)

"
I want one of those languages where if you accidently delete something
the compiler guesses what you meant and fixes it for you.
"
Try pascal:

begi

en

^ obvious what's missing there.

Also with call by reference no asterixes needed, so no asterixes can get
lost ! ;) =D

"
Some people just are not able to grasp (grok?) C well enough to
effectively program with it. Others are not meant to program at all.
"

As long as software is writing by humans there will be 1 bug per 10 lines of
code at least, that includes you ! ;) =D

Plus the rare occasional fok-up of accidently deleting something, then it's
nice to have pascal instead of c/c++.

I will fix such an accidently delete + save, in 1 second or so, you'll be
spending 1 hour trying to find that missing * or that missing } or that
missing { ;)

Bye,
Skybuck =D
 
S

Stephen Sprunk

"Stephen Sprunk" wrote in message

"
Only for those, such as you, who don't really understand C.
"

Nope, no asterixes needed = no extra bugs ! ;) =D

In C, the asterisks are required if you are working with pointers.
They're part of the language, not bugs.
"
No, if you accidentally delete one little asterisk someone, the compiler
warns you of a type mismatch, and you fix that and move on.
"

Perhaps, perhaps not, totally depends on the situation.

Please provide a counter-example, as I've never seen one. Perhaps a
compiler warning is a "crisis" to you, but not for someone with a decent
amount of experience and understanding of the language.

S
 
S

Skybuck Flying

"Stephen Sprunk" wrote in message
"Stephen Sprunk" wrote in message

"
Only for those, such as you, who don't really understand C.
"

Nope, no asterixes needed = no extra bugs ! ;) =D

"
In C, the asterisks are required if you are working with pointers.
They're part of the language, not bugs.
"

You acting dumb again, are you really that dumb ? ;) :)

Pascal doesn't need pointers for call by reference, thus no asterixes
needed, thus no bugs with asterixes ! ;) =D
"
No, if you accidentally delete one little asterisk someone, the compiler
warns you of a type mismatch, and you fix that and move on.
"

Perhaps, perhaps not, totally depends on the situation.

"
Please provide a counter-example, as I've never seen one. Perhaps a
compiler warning is a "crisis" to you, but not for someone with a decent
amount of experience and understanding of the language.
"

Then you sure haven’t programmed a lot:

I made a nice example for you, not a single warning ! ;)

void **********p1; // take a guess how many stars are missing ! ;):) Good
luck ! =D
int *p2;
p1 = NULL;
p2 = NULL;

p2 = (int *)(p1);
p2 = (int *)(&p2);

Bye,
Skybuck.
 
K

Keith Thompson

Skybuck Flying said:
"Stephen Sprunk" wrote in message

"
In C, the asterisks are required if you are working with pointers.
They're part of the language, not bugs.
"

You acting dumb again, are you really that dumb ? ;) :)

Pascal doesn't need pointers for call by reference, thus no asterixes
needed, thus no bugs with asterixes ! ;) =D
[...]

Everyone, please take a moment to consider whether feeding this
particular troll is a good use of your time and everyone else's
attention.

Thank you.
 
S

Skybuck Flying

"Keith Thompson" wrote in message
Skybuck Flying said:
"Stephen Sprunk" wrote in message

"
In C, the asterisks are required if you are working with pointers.
They're part of the language, not bugs.
"

You acting dumb again, are you really that dumb ? ;) :)

Pascal doesn't need pointers for call by reference, thus no asterixes
needed, thus no bugs with asterixes ! ;) =D
[...]

"
Everyone, please take a moment to consider whether feeding this
particular troll is a good use of your time and everyone else's
attention.
"

Lol sense when is stating the thruth trolling ?! ;) =D

You delirious ! ;) =D

Bye,
Skybuck ! ;) =DDDDD
 
A

Arivald

W dniu 2011-06-22 00:33, Keith Thompson pisze:
Skybuck Flying said:
"Stephen Sprunk" wrote in message

"
In C, the asterisks are required if you are working with pointers.
They're part of the language, not bugs.
"

You acting dumb again, are you really that dumb ? ;) :)

Pascal doesn't need pointers for call by reference, thus no asterixes
needed, thus no bugs with asterixes ! ;) =D
[...]

Everyone, please take a moment to consider whether feeding this
particular troll is a good use of your time and everyone else's
attention.

Maybe we should hire Witcher, to take case of this monster ;-)
 
D

David Thompson

On Sun, 19 Jun 2011 20:05:31 -0500, Shao Miller

There are other incomplete object types such as:

typedef char foo[];
struct bar;

Since an object of the former cannot be declared, I guess you wouldn't
have a problem, there.

Since an object of the latter cannot be declared until 'struct bar' is
defined, I guess you wouldn't have a problem, there.

Objects of those incomplete types can be declared, just not defined.

Array-of-unknown-bound can be completed by an initializer in the
definition, or for a tentative definition implicitly by the t.u. end
(although that gives you array-bound-1 which isn't highly useful).

Struct-tag-only can similarly be completed before a (compatible)
definition, or for a tentative definition by the t.u. end.
 
S

Shao Miller

On Sun, 19 Jun 2011 20:05:31 -0500, Shao Miller

There are other incomplete object types such as:

typedef char foo[];
struct bar;

Since an object of the former cannot be declared, I guess you wouldn't
have a problem, there.

Since an object of the latter cannot be declared until 'struct bar' is
defined, I guess you wouldn't have a problem, there.

Objects of those incomplete types can be declared, just not defined.

Array-of-unknown-bound can be completed by an initializer in the
definition, or for a tentative definition implicitly by the t.u. end
(although that gives you array-bound-1 which isn't highly useful).

Yes[6.9.2p2]. I suppose it would have been more accurate to have typed
"...an object of the former cannot be constructed/produced..."

Which, incidentally, makes me curious about GCC's 'typeof'...

typedef char a_char[];

a_char foo;
typeof(foo) bar;
a_char foo = "Test";

int main(void) {
return sizeof bar, 0;
}

Aha. 'bar' stays incomplete, versus with:

typedef char a_char[];

a_char foo;
a_char foo = "Test";
typeof(foo) bar;

int main(void) {
return sizeof bar, 0;
}
Struct-tag-only can similarly be completed before a (compatible)
definition, or for a tentative definition by the t.u. end.

Well, it might have been clearer if I'd been explicit about context. It
was in regards to Mr. J. Navia's "references" and possible
implementation problems he might have (I found one elsewhere; heh). I'm
not sure he'd be able to create a reference to such objects while those
objects have only been declared with an incomplete type. Is that a
mistaken impression, though?

typedef char a_char[];

a_char foo;

int main(void) {
a_char & bar = &foo;
return 0;
}

#if WITH_OR_WITHOUT
a_char foo = "Test";
#endif
 

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,091
Messages
2,570,604
Members
47,223
Latest member
smithjens316

Latest Threads

Top