initialization vs assignment

  • Thread starter Charles Stapleton
  • Start date
A

Alf P. Steinbach

* "Steven T. Hatton said:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}

Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".

This isn't homework, I hope?
 
S

Steven T. Hatton

Alf said:
* "Steven T. Hatton said:
Here's the question. Where (how) does the Holy Standard specify that I
can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}

Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".
Thanks!

This isn't homework, I hope?
No, it's the first question I asked in this newsgroup. Your response was
along the lines 'one might presume you would find that in the book'. But
you thought I was asking one of the questins you listed previously in this
thread. ;-)
 
C

Claudio Puviani

Steven T. Hatton said:
[more snipping than you can shake a stick at]

Here's the question. Where (how) does the Holy Standard
specify that I can do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}

8.5 (Initializers):

initializer:
= initializer clause
( expression-list )

.... and so on.

Claudio Puviani
 
A

Alf P. Steinbach

* (e-mail address removed) (Alf P. Steinbach) schriebt:
* "Steven T. Hatton said:
Here's the question. Where (how) does the Holy Standard specify that I can
do this:

int main(int argc, char* argv[]) {
int i(3); // <---<---
std::cout <<"i = " << i << std::endl;
}

Well that's another thing entirely. That's a "pseudo constructor
call". There's also "pseudo destructor call", but leave that for
the moment.

The standard (I'll leave off the mysticism for now, guess you had
enough of that in your meeting with Wheeler) discusses this in (click
on cpp.pdf, type ctrl-f, type in "pseudo constructor", nope, remember
that it is really cast notation, check §5.4, referred to §5.2.3 by
§5.4/2) §5.2.3/1 "Explicit type conversion (functional notation)".

Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.
If the standard were a computer program we'd refactor it. But with the
standard that would probably break too many references.

Now, hope this helps _this_ time...
 
L

Leor Zolman

Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.

It may be worth noting here that the use of pseudo-constructor syntax on
primitive types is what allows some templates to be written so that they
can be specialized for class /or/ primitive types. I'm not sure whether it
would be totally impossible, or just really ugly, without them.
-leor
 
S

Steven T. Hatton

Alf said:
Oops, forgot, that's just part of the "pseudo constructor" thing that
makes it seem like scalar types have constructors. The part you're
actually asking about with your example is the initialization syntax
in declarations. And that's called a "direct-initialization" and
is partially covered by §8.5 and by §12.3/1. So a "pseudo constructor",
which is not named as such in the standard, is a concept implemented
by a little bit here and a little bit there, sort of well hidden... ;-)

Possibly there are even more small bits scattered here & there, but the
main point is that it's a trivial concept (make it seem like those types
have constructors) implemented piecemeal here and there because of the
way the structure of the standard turned out as a collaborative design.
If the standard were a computer program we'd refactor it. But with the
standard that would probably break too many references.

I was wondering what a spaghetti diagram might look like. The Standard is
organized in a hierarchical structure using symbols such as [basic],
[basic.def],[basic.def.odr], etc.

http://www.itga.com.au/~gnb/wp/cd2/

There are extensive crossreferences pointing to different sections. I
wonder what it would look like if someone tried to pin it all up on a huge
tack board with lines connecting the references. Could it be treated as a
collection of objects in some kind of (pseudo-) UML diagram? It might also
be instructive to include the grammar in this spaghetti diagram.

Another thing that might be useful is a hyperlinked version of the Grammar
which took the user to discussion in the text, and/or examples using the
particular derivation.
Now, hope this helps _this_ time...

I'll have to review it all. Parts of the Standard are very hard to read
because they have a lot of forward references (if that's the proper term
for things mentioned but not yet defined). Other parts are easier to read
than TC++PL(SE) discussion of the same topic. I'm currently trying to slog
my way through Clause(?) 3 [basic]. The whole 'chapter'.
 

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,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top