By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,795 Members | 1,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,795 IT Pros & Developers. It's quick & easy.

initialization vs assignment

P: n/a
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.

-charles
Jul 22 '05 #1
Share this Question
Share on Google+
50 Replies


P: n/a
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor
Jul 22 '05 #2

P: n/a
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor
Jul 22 '05 #3

P: n/a
Charles Stapleton wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to
setting the member variables a and b using initialization, :a(i), as
opposed to using assignment, b = j.

-charles


IMHO, nothing, but when you have a variable of a class with no default
constructor, initialization is required.

- Pete
Jul 22 '05 #4

P: n/a
Charles Stapleton wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to
setting the member variables a and b using initialization, :a(i), as
opposed to using assignment, b = j.

-charles


IMHO, nothing, but when you have a variable of a class with no default
constructor, initialization is required.

- Pete
Jul 22 '05 #5

P: n/a
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.
For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).
-leor

-charles


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #6

P: n/a
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.
For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).
-leor

-charles


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #7

P: n/a
* Leor Zolman <le**@bdsoft.com> schriebt:
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).


For answers like these I think it's a good idea to refer to the FAQ.

FAQ: <url: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6>.

Unfortunately the FAQ does not mention the single most common "good" reason
to use assignment, namely, presence of initialization order dependencies.
Which should be designed away if possible, but that is sometimes impractical.
As a rule, if assignment is used instead of initialization list then either
there is an initialization order dependency or a newbie or both.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #8

P: n/a
* Leor Zolman <le**@bdsoft.com> schriebt:
On Sat, 03 Apr 2004 19:39:13 GMT, "Charles Stapleton" <cS********@no.junk>
wrote:
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


For non-const primitive types and references (though there are some good
reasons to avoid const members or refs as data members), the only advantage
is stylistic. If you happen to have a /mixture/ of primitive and class-type
data members (along with base classes, perhaps), then all the
initializations can be shown in the same place and in a uniform style.

For any type with constructors, though, omitting the member (or base)
initialization forces invocation of that class's default constructor before
the body of the constructor is entered. If you then do an assignment in the
body of your constructor (assuming assignment is even supported for that
type), you'll be doing "extra work". If there's no default constructor, it
won't compile (probably the better scenario, since you find out sooner that
you've got some kind of a problem).


For answers like these I think it's a good idea to refer to the FAQ.

FAQ: <url: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.6>.

Unfortunately the FAQ does not mention the single most common "good" reason
to use assignment, namely, presence of initialization order dependencies.
Which should be designed away if possible, but that is sometimes impractical.
As a rule, if assignment is used instead of initialization list then either
there is an initialization order dependency or a newbie or both.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #9

P: n/a
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #10

P: n/a
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting
the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #11

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?

Because
Jul 22 '05 #12

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Charles Stapleton" <cS********@no.junk> wrote...
Given the folowing class

class Ctest{
public:
Ctest( int i, int j) :a(i) { b = j; }
private:
int a, b;
}

When creating an object of type Ctest, what advantage is there to setting the member variables a and b using initialization, :a(i), as opposed to
using assignment, b = j.


This is answered in the FAQ Lite (you can find it if you follow the
link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
before posting.

Victor

Why?

Because
Jul 22 '05 #13

P: n/a
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to setting >> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor

Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #14

P: n/a
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to setting >> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor

Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #15

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all over
the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first place,
but then MIT has not only the best & brightest of the US population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented university.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #16

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all over
the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first place,
but then MIT has not only the best & brightest of the US population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented university.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #17

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:

> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to

setting
>> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor
Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


It could just as well be taken at its face value. What's your F point?
Jul 22 '05 #18

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote...
Victor Bazarov wrote:

> "Charles Stapleton" <cS********@no.junk> wrote...
>> Given the folowing class
>>
>> class Ctest{
>> public:
>> Ctest( int i, int j) :a(i) { b = j; }
>> private:
>> int a, b;
>> }
>>
>> When creating an object of type Ctest, what advantage is there to

setting
>> the member variables a and b using initialization, :a(i), as opposed
>> to using assignment, b = j.
>
> This is answered in the FAQ Lite (you can find it if you follow the
> link http://www.parashift.com/c++-faq-lite/). Please read the FAQ
> before posting.
>
> Victor
Why?

Because


It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


It could just as well be taken at its face value. What's your F point?
Jul 22 '05 #19

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #20

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.


Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #21

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.


Hah, one should never needlessly limit an attack to person and country, as I
am sure your mother told you.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.
Yada yada yada, "AFAIK there are many good negroes, jews, japs, frogs, etc.,
and one of my best friends is a lesbian". Actually there are. One of the
nice things about Norway is the humanitarian outlook (it's nice in general,
but as commented earlier not so good with respect to technical education).
E.g. we were early (1981) with having a female prime minister (Gro Harlem
Brundtland, <url: http://tinyurl.com/26x63>); then a female and lesbian
minister of justice (Anne Holt, who now mainly writes detective novels, <url:
http://tinyurl.com/34uby>, <url: http://tinyurl.com/yuqcc>), and currently a
male homosexual minister of economy (Per-Kristian Foss, <url:
http://tinyurl.com/3fsdm>) with a priest (Kjell Magne Bondevik, <url:
http://tinyurl.com/2azkv>) as prime minister -- we're simply not bigots, we
don't have that in us, but look at the US... When is the first lesbian
president or even member of Congress expected in the US? Never, I think;
and to take but one little example from current political debate, note that
in Per-Kristian Foss' official CV (from the Norwegian government), referred
above, he lives in a registered partnership -- when is that in the US?

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.


RTFM on topicality.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #22

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

It seems to me 'Please read the FAQ before posting' could be taken as
'Please RTFFAQ'.
Just spell it out: Read The Fucking Manual.

With prudish & easily offended Americans (who, without noticing any of it,
offend all others not by their choice of words but by their actions) all
over the net, however, it is perhaps best not asserted in that form.

It's a mystery to me how MIT could set up the RTFM site in the first
place, but then MIT has not only the best & brightest of the US
population, but also
many bright people from the rest of the world. I am quite sure that in
current Norway, striving to be more American than the Americans, something
like the RTFM could never have been set up. But then we no longer have
any
technical educational institutions left in Norway -- the miniature MIT
called NTH was, a few years ago, subsumed by a humanities oriented
university.


It's not the idea of pointing people to the FAQ that I was addressing. It
was the confrontational undercurrent that seems to lie just below the
surface. Say the wrong thing on the newsgroup and the next thing you know,
you'll have someone going berserk and using profanity in some kind of flame
attacking not only you, but your country, and who knows what else.


Hah, one should never needlessly limit an attack to person and country, as I
am sure your mother told you.

Sorry if I don't follow suit by attacking your country. AFAIK, there are
many good people in Norway whom I don't wish to offend.
Yada yada yada, "AFAIK there are many good negroes, jews, japs, frogs, etc.,
and one of my best friends is a lesbian". Actually there are. One of the
nice things about Norway is the humanitarian outlook (it's nice in general,
but as commented earlier not so good with respect to technical education).
E.g. we were early (1981) with having a female prime minister (Gro Harlem
Brundtland, <url: http://tinyurl.com/26x63>); then a female and lesbian
minister of justice (Anne Holt, who now mainly writes detective novels, <url:
http://tinyurl.com/34uby>, <url: http://tinyurl.com/yuqcc>), and currently a
male homosexual minister of economy (Per-Kristian Foss, <url:
http://tinyurl.com/3fsdm>) with a priest (Kjell Magne Bondevik, <url:
http://tinyurl.com/2azkv>) as prime minister -- we're simply not bigots, we
don't have that in us, but look at the US... When is the first lesbian
president or even member of Congress expected in the US? Never, I think;
and to take but one little example from current political debate, note that
in Per-Kristian Foss' official CV (from the Norwegian government), referred
above, he lives in a registered partnership -- when is that in the US?

But the FAQ, does address this issue. Please take a look at the FAQ before
replying. I believe you might find the discussion enlightening.


RTFM on topicality.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #23

P: n/a
Alf P. Steinbach wrote:
RTFM on topicality.

I trust you can find a Norwegian translation of the Hvaml by starting
here: http://www.forn-sed.no/main/nynorsk/informasjon.htm

From the Old Norse:

9. S er sll
er sjlfr of
lof ok vit, mean lifir;
v at ill r
hefr mar oft egit
annars brjstum r.

10. Byri betri
berr-at mar brautu at
en s mannvit mikit;
aui betra
ykkir at kunnum sta;
slkt er vlas vera.

11. Byri betri
berr-at mar brautu at
en s mannvit mikit;
vegnest verra
vegr-a hann velli at
en s ofdrykkja ls.

12. Er-a sv gtt
sem gtt kvea
l alda sonum,
v at fra veit
er fleira drekkr
sns til ges gumi.

13. minnishegri heitir
s er yfir lrum rumir;
hann stelr gei guma;
ess fugls fjrum
ek fjtrar vark
gari Gunnlaar.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #24

P: n/a
Alf P. Steinbach wrote:
RTFM on topicality.

I trust you can find a Norwegian translation of the Hvaml by starting
here: http://www.forn-sed.no/main/nynorsk/informasjon.htm

From the Old Norse:

9. S er sll
er sjlfr of
lof ok vit, mean lifir;
v at ill r
hefr mar oft egit
annars brjstum r.

10. Byri betri
berr-at mar brautu at
en s mannvit mikit;
aui betra
ykkir at kunnum sta;
slkt er vlas vera.

11. Byri betri
berr-at mar brautu at
en s mannvit mikit;
vegnest verra
vegr-a hann velli at
en s ofdrykkja ls.

12. Er-a sv gtt
sem gtt kvea
l alda sonum,
v at fra veit
er fleira drekkr
sns til ges gumi.

13. minnishegri heitir
s er yfir lrum rumir;
hann stelr gei guma;
ess fugls fjrum
ek fjtrar vark
gari Gunnlaar.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #25

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hvaml


The English translation is actually more understandable.

Have you considered verses 1 through 8, not just 9 through 13? ;-)

Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ. What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".

Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #26

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hvaml


The English translation is actually more understandable.

Have you considered verses 1 through 8, not just 9 through 13? ;-)

Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ. What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".

Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #27

P: n/a
PS: My information about the US Congress turned out to be out of date.
It actually had Tammy Baldwin in 1998. So my guess was partially
incorrect.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #28

P: n/a
PS: My information about the US Congress turned out to be out of date.
It actually had Tammy Baldwin in 1998. So my guess was partially
incorrect.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #29

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hvaml
The English translation is actually more understandable.


They all seem lacking to me. I prefer the Old Norse.
Have you considered verses 1 through 8, not just 9 through 13? ;-)
Certainly, but they didn't seem as apropos.
Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ.
I didn't say it was equivalent. I said it might be taken that way.
What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".
I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf


What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #30

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I trust you can find a Norwegian translation of the Hvaml
The English translation is actually more understandable.


They all seem lacking to me. I prefer the Old Norse.
Have you considered verses 1 through 8, not just 9 through 13? ;-)
Certainly, but they didn't seem as apropos.
Seriously, please don't more times suggest that the ordinary and polite
way to steer someone to the FAQ -- as Victor did -- is equivalent to
RTFFAQ.
I didn't say it was equivalent. I said it might be taken that way.
What you did there was to break two rules for visitors to the
house. Hinting (it seemed like) about Victor's motives, like "so you
really meant [bad thing]", and second, like "your customs are ungood".
I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
Now I've tried both humor, low-intensity flaming and simple explanation.

I should perhaps have tried the last first, but done is done.
Cheers,

- Alf


What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #31

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
I guess you mean why it should be preferred over assignment. In this
case, with 'int' type, and nothing else going on in the constructor, I
see no technical reason and no readability reason. But it's like
a car driver indicating which way he's about to drive at crossroads even
when there are no other cars in sight: the habit helps to do the Right
Thing in general, and perhaps there's someone waiting to cross the
street, just not very clearly in sight, making the decision to cross...

Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.

What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.


I'm not sure whether this is some subtle thing or a hint about off-topicality
or an effort to convince me that you are no dummy (I do know, at least if
earlier comments about implementing mathematical models is true), or boasting,
or what. But it doesn't seem very relevant. If it's simply "by the way I met
a famous person", well most of us have; e.g. I shook hands with Bill Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to a
shop by security guards, then came Bill, and of course he had to shake hands
with a beautiful lady beside me, and another one, and then for consistency
with me too as the last person before the entrance to the shop. Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in the
span of just one week, and actually shook hands with one of them!

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #32

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
int getX(){return m_x; };
};

int main(int argc, char* argv[]) {
A a(5);
std::cout << a.getX() << std::endl;
}
I guess you mean why it should be preferred over assignment. In this
case, with 'int' type, and nothing else going on in the constructor, I
see no technical reason and no readability reason. But it's like
a car driver indicating which way he's about to drive at crossroads even
when there are no other cars in sight: the habit helps to do the Right
Thing in general, and perhaps there's someone waiting to cross the
street, just not very clearly in sight, making the decision to cross...

Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.

What Gore really meant when he pointed to his work with the Internet was not
that he invented the Internet - which he never said - but that he did a lot
to popularize it, and disseminate information about the use of web browsers
to people in prominant and influential positions. I set up the systems he
use to do it.


I'm not sure whether this is some subtle thing or a hint about off-topicality
or an effort to convince me that you are no dummy (I do know, at least if
earlier comments about implementing mathematical models is true), or boasting,
or what. But it doesn't seem very relevant. If it's simply "by the way I met
a famous person", well most of us have; e.g. I shook hands with Bill Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to a
shop by security guards, then came Bill, and of course he had to shake hands
with a beautiful lady beside me, and another one, and then for consistency
with me too as the last person before the entrance to the shop. Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in the
span of just one week, and actually shook hands with one of them!

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #33

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.
I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)
Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.
Thanks for the pointer, I still have a lot to internalize.
What Gore really meant when he pointed to his work with the Internet was
not that he invented the Internet - which he never said - but that he did
a lot to popularize it, and disseminate information about the use of web
browsers
to people in prominant and influential positions. I set up the systems
he use to do it.
I'm not sure whether this is some subtle thing


The point was I might be a bit new to this particular newsgroup, but I'm not
new to usenet. At some point I'm no longer a newbie in this newsgroup.
For me to comment on how others are treated is not necessarily improper for
a guest (the Hvaml is the song of a wandering singer), but I think I've
been around long enough to not qualify as a newbie.
But it doesn't seem very relevant. If it's simply "by the way I met a famous person", well most of us have; e.g. I shook hands with Bill
Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to
a shop by security guards, then came Bill, and then for consistency with me too as the last person before the
entrance to the shop.


I hope you washed your hand with hot water and soap before touching
anything, especially your face, or other sensitive part of your body.
Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it
wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in
the span of just one week, and actually shook hands with one of them!


I met Stephen Wolfram, and didn't even know it at the time. I never met
Gore, I just set up the systems. I'm far more pleased to have had a chance
to meet and interact with John A. Wheeler, than I would be to have met
Gore.

http://pupgg.princeton.edu/www/jh/an...symposium.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #34

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.
I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)
Btw., by declaring 'getX' as a 'const' member function it will be
possible to call it also on 'const' A-objects.
Thanks for the pointer, I still have a lot to internalize.
What Gore really meant when he pointed to his work with the Internet was
not that he invented the Internet - which he never said - but that he did
a lot to popularize it, and disseminate information about the use of web
browsers
to people in prominant and influential positions. I set up the systems
he use to do it.
I'm not sure whether this is some subtle thing


The point was I might be a bit new to this particular newsgroup, but I'm not
new to usenet. At some point I'm no longer a newbie in this newsgroup.
For me to comment on how others are treated is not necessarily improper for
a guest (the Hvaml is the song of a wandering singer), but I think I've
been around long enough to not qualify as a newbie.
But it doesn't seem very relevant. If it's simply "by the way I met a famous person", well most of us have; e.g. I shook hands with Bill
Clinton
last time he was in Oslo -- I was prevented from leaving the entrance to
a shop by security guards, then came Bill, and then for consistency with me too as the last person before the
entrance to the shop.


I hope you washed your hand with hot water and soap before touching
anything, especially your face, or other sensitive part of your body.
Later the
same week I met a famous (in Norway and Italy) Norwegian pop-star, Lene
Marlin, or at least I think I did, but being afraid that possibly it
wasn't
her I didn't dare to say hello. Barring a major fault in the pop-star
recognition circuits, however, I think I met two very famous persons in
the span of just one week, and actually shook hands with one of them!


I met Stephen Wolfram, and didn't even know it at the time. I never met
Gore, I just set up the systems. I'm far more pleased to have had a chance
to meet and interact with John A. Wheeler, than I would be to have met
Gore.

http://pupgg.princeton.edu/www/jh/an...symposium.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #35

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean by
formal language mechanism is the C++ definition of initializer list. You'll
find that in section 12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.

Possibility 2: what you mean by formal language mechanism is a language-
independent thing that 12.6.2 is the C++ language implementation of. Sorry,
can't help you there. Except that it's possible to find formal definitions
of just about anything just by looking and searching hard enough; and if one
does not exist it can always be produced.

Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it? Well, one thing
that is different between Java and C++ is that a Java object of a type with
constructor can only be referred to by reference, whereas in C++ it can be
a local variable say (or directly occupy storage in another object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design choice
is then between (A) not having automatic constructor calls but instead require
the equivalent of placement new for all subobjects, one can't just leave the
members as null-references as in Java, and (B) having automatic constructor
calls, in which case additional initialization in the constructor body will
be inefficient, and there is the problem of providing constructor arguments.
C++ uses solution (B), and solves the both inefficiency problem and the
argument passing problem with the constructor initializer lists mechanism.

In addition constructor initializer lists solve the problem of initializing
const members.

But an alternative to that could be not to design the language with const
members but with 'readonly' members which turn to 'readonly' state only
after the constructor has finished.

I met Stephen Wolfram, and didn't even know it at the time.
You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:

perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'

John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #36

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:

I still don't fully understand /why/ m_x(x) works in the following:

#include <iostream>

class A {
int m_x;
public:
A(int x):m_x(x){};
I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism. That's
why I'm sitting here with the Standard and a highlighter. Yes, it's in
hardcopy printed using psutils. I'm not using the highlighter on the
electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean by
formal language mechanism is the C++ definition of initializer list. You'll
find that in section 12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.

Possibility 2: what you mean by formal language mechanism is a language-
independent thing that 12.6.2 is the C++ language implementation of. Sorry,
can't help you there. Except that it's possible to find formal definitions
of just about anything just by looking and searching hard enough; and if one
does not exist it can always be produced.

Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it? Well, one thing
that is different between Java and C++ is that a Java object of a type with
constructor can only be referred to by reference, whereas in C++ it can be
a local variable say (or directly occupy storage in another object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design choice
is then between (A) not having automatic constructor calls but instead require
the equivalent of placement new for all subobjects, one can't just leave the
members as null-references as in Java, and (B) having automatic constructor
calls, in which case additional initialization in the constructor body will
be inefficient, and there is the problem of providing constructor arguments.
C++ uses solution (B), and solves the both inefficiency problem and the
argument passing problem with the constructor initializer lists mechanism.

In addition constructor initializer lists solve the problem of initializing
const members.

But an alternative to that could be not to design the language with const
members but with 'readonly' members which turn to 'readonly' state only
after the constructor has finished.

I met Stephen Wolfram, and didn't even know it at the time.
You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:

perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'

John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #37

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
> * "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
>>
>> I still don't fully understand /why/ m_x(x) works in the following:
>>
>> #include <iostream>
>>
>> class A {
>> int m_x;
>> public:
>> A(int x):m_x(x){};
> I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism.
That's why I'm sitting here with the Standard and a highlighter. Yes,
it's in hardcopy printed using psutils. I'm not using the highlighter on
the electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean
by
formal language mechanism is the C++ definition of initializer list.
You'll
find that in section 12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.


Thanks for the pointer. But that's not what has me puzzled.
Possibility 2: what you mean by formal language mechanism is a language-
independent thing that 12.6.2 is the C++ language implementation of.
I don't believe it's an implementation issue.
Sorry,
can't help you there. Except that it's possible to find formal
definitions of just about anything just by looking and searching hard
enough; and if one does not exist it can always be produced.
Nobody ever responded to my question about what else significant is on the
page of K&R in the Grammar where the function main() is specified. I
wonder why.
Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it?
Nope.
Well, one
thing that is different between Java and C++ is that a Java object of a
type with constructor can only be referred to by reference, whereas in C++
it can be a local variable say (or directly occupy storage in another
object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design
choice is then between (A) not having automatic constructor calls but
instead require the equivalent of placement new for all subobjects, one
can't just leave the members as null-references as in Java, and (B) having
automatic constructor calls, in which case additional initialization in
the constructor body will be inefficient, and there is the problem of
providing constructor arguments. C++ uses solution (B), and solves the
both inefficiency problem and the argument passing problem with the
constructor initializer lists mechanism.
I guess there are advantages to any of the approaches. Java is a very
regular language which may be a bit awkward at times, but it's also
straightforward. C++ reminds me of something Mithrandir might study. There
seems to be a lot of magic in it. Hard to master, hard to perceive, but
powerful when you do master it.
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;
}
I met Stephen Wolfram, and didn't even know it at the time.


You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:


I don't know if I'm susceptible to fullblown Cellular Automata. I've done a
lot of fun stuff in Mathematica, but there is something fundamental I have
yet to grasp. It may be something it shares with Lisp, which I've never
mastered. I know it has to do with up-values. But I don't even want to
think about that right now.
perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'
And you suggested "UBC" was profane in C++ circles? ;-)
John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)


Don't know the book, but this will tell you more about Wheeler:
http://www.usd.edu/phys/courses/phys...k/wheeler.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #38

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
Alf P. Steinbach wrote:
> * "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
>>
>> I still don't fully understand /why/ m_x(x) works in the following:
>>
>> #include <iostream>
>>
>> class A {
>> int m_x;
>> public:
>> A(int x):m_x(x){};
> I guess you mean why it should be preferred over assignment.


I don't know what formal language principle underlies the mechanism.
That's why I'm sitting here with the Standard and a highlighter. Yes,
it's in hardcopy printed using psutils. I'm not using the highlighter on
the electronic version in PDF! :-)


Again I'm not quite sure what you mean. But possibility 1: what you mean
by
formal language mechanism is the C++ definition of initializer list.
You'll
find that in section 12.6.2 of the Holy Standard. With the colon it's
called a ctor-initializer, and sans the colon it's a mem-initializer-list.


Thanks for the pointer. But that's not what has me puzzled.
Possibility 2: what you mean by formal language mechanism is a language-
independent thing that 12.6.2 is the C++ language implementation of.
I don't believe it's an implementation issue.
Sorry,
can't help you there. Except that it's possible to find formal
definitions of just about anything just by looking and searching hard
enough; and if one does not exist it can always be produced.
Nobody ever responded to my question about what else significant is on the
page of K&R in the Grammar where the function main() is specified. I
wonder why.
Possibility 3: what you mean by formal language mechanism is what purpose
does it serve, when e.g. Java seems to do well without it?
Nope.
Well, one
thing that is different between Java and C++ is that a Java object of a
type with constructor can only be referred to by reference, whereas in C++
it can be a local variable say (or directly occupy storage in another
object, or
static storage). To ensure type safety -- that all member objects with
constructors have their constructors called -- the language design
choice is then between (A) not having automatic constructor calls but
instead require the equivalent of placement new for all subobjects, one
can't just leave the members as null-references as in Java, and (B) having
automatic constructor calls, in which case additional initialization in
the constructor body will be inefficient, and there is the problem of
providing constructor arguments. C++ uses solution (B), and solves the
both inefficiency problem and the argument passing problem with the
constructor initializer lists mechanism.
I guess there are advantages to any of the approaches. Java is a very
regular language which may be a bit awkward at times, but it's also
straightforward. C++ reminds me of something Mithrandir might study. There
seems to be a lot of magic in it. Hard to master, hard to perceive, but
powerful when you do master it.
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;
}
I met Stephen Wolfram, and didn't even know it at the time.


You would have been infected with cellular automata. But I rather liked
his program for displaying Sierpinski-like triangles. Since this is a C++
newsgroup, here's the Perl version, courtesy of Lars Christian Jensen:


I don't know if I'm susceptible to fullblown Cellular Automata. I've done a
lot of fun stuff in Mathematica, but there is something fundamental I have
yet to grasp. It may be something it shares with Lisp, which I've never
mastered. I know it has to do with up-values. But I don't even want to
think about that right now.
perl -e 'for$a(0..63){for(0..$a){print($_&~$a?" ":"#")}print"\n"}'
And you suggested "UBC" was profane in C++ circles? ;-)
John A. Wheeler


For some reason he reminds me of the book "wheelers" by Ian Stewart... ;-)


Don't know the book, but this will tell you more about Wheeler:
http://www.usd.edu/phys/courses/phys...k/wheeler.html
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #39

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #40

P: n/a
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #41

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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. ;-)
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #42

P: n/a
Alf P. Steinbach wrote:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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. ;-)
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #43

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote

[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
Jul 22 '05 #44

P: n/a
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote

[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
Jul 22 '05 #45

P: n/a
* al***@start.no (Alf P. Steinbach) schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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...

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #46

P: n/a
* al***@start.no (Alf P. Steinbach) schriebt:
* "Steven T. Hatton" <su******@setidava.kushan.aa> schriebt:
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...

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #47

P: n/a
On Sun, 04 Apr 2004 15:11:38 GMT, al***@start.no (Alf P. Steinbach) wrote:
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

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #48

P: n/a
On Sun, 04 Apr 2004 15:11:38 GMT, al***@start.no (Alf P. Steinbach) wrote:
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

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #49

P: n/a
Alf P. Steinbach wrote:
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'.
--
p->m == (*p).m == p[0].m
http://www.kdevelop.org
http://www.suse.com
http://www.mozilla.org
Jul 22 '05 #50

50 Replies

This discussion thread is closed

Replies have been disabled for this discussion.