Why can't PODs have constructors?

J

James Kanze

The one above is the only constructor (once you declare/define one, the
compiler does not).

Not quite. There's also a compiler generated copy constructor.
 
B

BobR

James Kanze wrote in message...

/* """ quote
JohnQ wrote in message...
The one above is the only constructor (once you declare/define one, the
compiler does not).

Not quite. There's also a compiler generated copy constructor.
""" */

Thanks James. I posted late night, and started to re-post an addition, but,
was talking about constructors only. Copy-constructors are, to me, an
separate column. Like the old Chinese restaurant menu, one from column A,
one from column B, etc. (Ctor, CCtor, op=, Dtor). (what, two from column A?
that will be another $2.75! only one in col D, the Dessert-tor (when you
finish that, the meal is over.)).

Without an constructor, a copy-constructor seems pretty useless (how would
you get an instance to copy? <G>).
 
J

James Kanze

James Kanze wrote in message...
Thanks James. I posted late night, and started to re-post an
addition, but, was talking about constructors only.
Copy-constructors are, to me, an separate column.

I know what you mean. From a language point of view, it may
always be a constructor, but from a logical point of view, I,
too, tend to think of creating a new object as somehow different
from creating a copy. I even have a few special cases where I
keep count of the copies, and the "real" destruction---something
like freeing the resource in RAII---only takes place when the
last copy is destructed. (Boost::shared_ptr is a special case
of this particular idiom.)
Like the old Chinese restaurant menu, one from column A,
one from column B, etc. (Ctor, CCtor, op=, Dtor).

More likely, either everything from column B, or nothing:).
(what, two from column A?
that will be another $2.75! only one in col D, the Dessert-tor (when you
finish that, the meal is over.)).
Without an constructor, a copy-constructor seems pretty
useless (how would you get an instance to copy? <G>).

Quite. If you have a user defined copy-constructor (which
inhibits the automatic generation of a default constructor),
you'd better have at least one other user defined constructor as
well.
 
G

Geo

Well how about leaving 'struct' alone and defining a new keyword:
'PODStruct'? Then even "no padding or aligning allowed" could be also
included in the spec making for some nice IO scenarios. Slowly, 'struct'
would be deprecated.

John

'no padding or aligning allowed', would that be a requirement, if so
it ain't gonna be very portable !!!!
 
J

JohnQ

Geo said:
'no padding or aligning allowed', would that be a requirement, if so
it ain't gonna be very portable !!!!

It will be when hardware vendors get their acts together. Until then, I'll
just byte-align on WinTel and not worry about Sparcs and Crays. Anyways, if
you want to give the compiler free reign to do what it wants, use the
'class' keyword instead of PODStruct, as they are different animals for
different purposes (in the hypothetical scenario given).

John
 
J

JohnQ

"Geo" <[email protected]> wrote in message

[...]
It will be when hardware vendors get their acts together.

"They have their acts together. It's you that don't seem to
understand."

I won't be buying that Brooklyn bridge either, thank you.
Until then, I'll just byte-align on WinTel

"And pay an extremely high performance penalty for it."

You're assuming that byte-aligning struct members implies non-optimum
alignment. That's a wrong assumption. And perhaps you're thinking that
everything has to be byte-aligned or not, which isn't the case either.

"More than a few applications can't afford that."

There is no penalty if you define your stucts correctly so that the data
members align. Secondly, the vast majority of applications are not
performance constrained. Indeed, they are IO constrained if anything, so not
having to marshal will speed up the program (on the "native" platform).

John
 
J

James Kanze

On Aug 1, 1:29 am, "JohnQ" <[email protected]>
wrote:
[...]
'no padding or aligning allowed', would that be a
requirement, if so it ain't gonna be very portable !!!!
It will be when hardware vendors get their acts together.
"They have their acts together. It's you that don't seem to
understand."
I won't be buying that Brooklyn bridge either, thank you.

You won't be writing any good software, either.
"And pay an extremely high performance penalty for it."
You're assuming that byte-aligning struct members implies non-optimum
alignment. That's a wrong assumption. And perhaps you're thinking that
everything has to be byte-aligned or not, which isn't the case either.
"More than a few applications can't afford that."
There is no penalty if you define your stucts correctly so that the data
members align.

Which, of course, depends on the machine.
Secondly, the vast majority of applications are not
performance constrained. Indeed, they are IO constrained if
anything, so not having to marshal will speed up the program
(on the "native" platform).

You always have to marshall. Objects aren't just arrays of
bytes, regardless of what you think.

(FWIW: our applications are very IO bound. That's why we use
Sparc's, and not PC's.)
 
J

JohnQ

On Aug 1, 1:29 am, "JohnQ" <[email protected]>
wrote:
[...]
'no padding or aligning allowed', would that be a
requirement, if so it ain't gonna be very portable !!!!
It will be when hardware vendors get their acts together.
"They have their acts together. It's you that don't seem to
understand."
I won't be buying that Brooklyn bridge either, thank you.

"You won't be writing any good software, either."

More propoganda.
"And pay an extremely high performance penalty for it."
You're assuming that byte-aligning struct members implies non-optimum
alignment. That's a wrong assumption. And perhaps you're thinking that
everything has to be byte-aligned or not, which isn't the case either.
"More than a few applications can't afford that."
There is no penalty if you define your stucts correctly so that the data
members align.

"Which, of course, depends on the machine."

Designate one as primary.
Secondly, the vast majority of applications are not
performance constrained. Indeed, they are IO constrained if
anything, so not having to marshal will speed up the program
(on the "native" platform).

"You always have to marshall. Objects aren't just arrays of
bytes, regardless of what you think."

"Objects" has too much connotation. You can make something that is "just an
array of bytes". Indeed, that is fundamental and any language that doesn't
facilitate that is defficient (or trying to sell compilers).

John
 
J

James Kanze

On Aug 1, 12:58 pm, "JohnQ" <[email protected]>
wrote:
On Aug 1, 1:29 am, "JohnQ" <[email protected]>
wrote:
[...]
'no padding or aligning allowed', would that be a
requirement, if so it ain't gonna be very portable !!!!
It will be when hardware vendors get their acts together.
"They have their acts together. It's you that don't seem to
understand."
I won't be buying that Brooklyn bridge either, thank you.
"You won't be writing any good software, either."
More propoganda.

More reality. I've been at this business long enough to
recognize incompetence when I see it. If you don't understand
the necessity of marshalling, or of different processor
architectures, you're never going to write any quality software.
Designate one as primary.

Primary what? Different people have different requirements, so
there are different architectures out there to solve them. I
work mainly on large scale servers, and I certainly don't want
to be forced to use an ARM architecture, just because it's the
most widespread. (I don't even really know the ARM
architecture, so little is it relevant to my field of work,
where Sparc is by far the dominant architecture.)
"Objects" has too much connotation. You can make something
that is "just an array of bytes".

Not really. Not anything very useful, anyway.
Indeed, that is fundamental and any language that doesn't
facilitate that is defficient (or trying to sell compilers).

Or trying to support users who are writing real applications,
and need to manage complexity.
 
J

JohnQ

On Aug 1, 12:58 pm, "JohnQ" <[email protected]>
wrote:
On Aug 1, 1:29 am, "JohnQ" <[email protected]>
wrote:
[...]
'no padding or aligning allowed', would that be a
requirement, if so it ain't gonna be very portable !!!!
It will be when hardware vendors get their acts together.
"They have their acts together. It's you that don't seem to
understand."
I won't be buying that Brooklyn bridge either, thank you.
"You won't be writing any good software, either."
More propoganda.

"More reality. I've been at this business long enough to
recognize incompetence when I see it. If you don't understand
the necessity of marshalling, or of different processor
architectures, you're never going to write any quality software."

You're marshalling everywhere, all the time and calling me stupid? Have you
considered getting some bran in your diet? Maybe you wouldn't be so ornery
then. :p
Designate one as primary.

"Primary what? Different people have different requirements, so
there are different architectures out there to solve them. I
work mainly on large scale servers, and I certainly don't want
to be forced to use an ARM architecture, just because it's the
most widespread. (I don't even really know the ARM
architecture, so little is it relevant to my field of work,
where Sparc is by far the dominant architecture.)"

Nevermind, you don't get it.
"Objects" has too much connotation. You can make something
that is "just an array of bytes".

"Not really. Not anything very useful, anyway."

You fo right ahead and keep maintaining the complexity. That's your
perogative.
Indeed, that is fundamental and any language that doesn't
facilitate that is defficient (or trying to sell compilers).

"Or trying to support users who are writing real applications,
and need to manage complexity."

Broken record.

John
 

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
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top