Tuesday, April 28, 2009

comp.lang.c++ - 25 new messages in 10 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* Is it legal to directly call a constructor? - 8 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/562e9b8fa0a08333?hl=en
* C++ is complicated - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/ec94a39f632a6c05?hl=en
* Ascii Characters - 6 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/b426276abbbce135?hl=en
* Free shipping wholesale Nike Gucci Dior POLO LV D&G Lacoste BOSS shoes ,
handbags,Clothing@,shirt,glass ,PayPal - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/fd0e5d6df2be8b24?hl=en
* Free shipping wholesale Nike Gucci Dior POLO LV D&G Lacoste BOSS shoes ,
handbags,Clothing,shirt,glass, payment PayPal - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/112c7632d8bc89ec?hl=en
* Polymorphism at run-time - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/afb5fdfa6ae286c5?hl=en
* Optimizer Behavior with a Comparison - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/7e633f44fe066f5f?hl=en
* Replica brand handbags wallets good quality wholesale from china www.
guoshitrade.com paypal payment - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ffe43fcab61807aa?hl=en
* Deitel &Deitel How to Program C++ 6th Edition full Code solutions contact
allsolutionmanuals11[at]gmail.com - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/bfe24e37a5338ca1?hl=en
* New Style Designer Sunglasses - discount - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/82cf166d3965f995?hl=en

==============================================================================
TOPIC: Is it legal to directly call a constructor?
http://groups.google.com/group/comp.lang.c++/t/562e9b8fa0a08333?hl=en
==============================================================================

== 1 of 8 ==
Date: Tues, Apr 28 2009 6:02 am
From: goodbyeera@gmail.com


Thank you very much for your reply.

> >  This
> > compiles OK in VC and GCC, but fails in Comeau.
>
> It shouldn't compile with any compiler.
>
> For g++, have you remembered to specify -pedantic and -std=c++98?
I have to apologize that the code in the original post doesn't compile
in g++. It's my mistake. However, the following code compiles in g++
and vc.
class A {};
int main()
{
A::A();
}
Is this syntactically legal in standard C++? I only know that "A()"
is the syntax used to create a temporary object of A.
And even more, the following code compiles in g++ (but not in vc).
#include <typeinfo>
class A {};
int main()
{
typeid(A::A);
}
What does this mean?
PS: By saying g++, actually I'm using mingw through dev-c++ on
windows.
>
> For VC, which version?
The code in the original post compiles in VC2008SP1.


== 2 of 8 ==
Date: Tues, Apr 28 2009 6:17 am
From: "Alf P. Steinbach"


* goodbyeera@gmail.com:
> Thank you very much for your reply.
>
>>> This
>>> compiles OK in VC and GCC, but fails in Comeau.
>> It shouldn't compile with any compiler.
>>
>> For g++, have you remembered to specify -pedantic and -std=c++98?
> I have to apologize that the code in the original post doesn't compile
> in g++. It's my mistake. However, the following code compiles in g++
> and vc.
> class A {};
> int main()
> {
> A::A();
> }
> Is this syntactically legal in standard C++?

Yes, AFAIK (regarding the qualification with A::, but check the standard if it
matters). It constructs a temporary of type A.


> I only know that "A()"
> is the syntax used to create a temporary object of A.

Yes.


> And even more, the following code compiles in g++ (but not in vc).
> #include <typeinfo>
> class A {};
> int main()
> {
> typeid(A::A);
> }
> What does this mean?

typeid is a built-in operator.

C++ allows any expression that produces a value, void, or a reference, to be
used as a statement; this includes writing e.g.

42;

You should up the compiler's warning level to get some diagnostic.

Check your documentation (textbook, C++ standard, whatever) regarding typeid.


> PS: By saying g++, actually I'm using mingw through dev-c++ on
> windows.
>> For VC, which version?
> The code in the original post compiles in VC2008SP1.

It really shouldn't.

But have you checked the compiler's documentation about non-conformance issues?

It might be (and probably is) a VC-specific language extension, for backwards
compatibility with pre-standard code.


Cheers & hth.,

- Alf

--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!


== 3 of 8 ==
Date: Tues, Apr 28 2009 6:24 am
From: Victor Bazarov


goodbyeera@gmail.com wrote:
> Thank you very much for your reply.
>
>>> This
>>> compiles OK in VC and GCC, but fails in Comeau.
>> It shouldn't compile with any compiler.
>>
>> For g++, have you remembered to specify -pedantic and -std=c++98?
> I have to apologize that the code in the original post doesn't compile
> in g++. It's my mistake. However, the following code compiles in g++
> and vc.
> class A {};
> int main()
> {
> A::A();
> }
> Is this syntactically legal in standard C++? I only know that "A()"
> is the syntax used to create a temporary object of A.
> And even more, the following code compiles in g++ (but not in vc).
> #include <typeinfo>
> class A {};
> int main()
> {
> typeid(A::A);
> }
> What does this mean?
> PS: By saying g++, actually I'm using mingw through dev-c++ on
> windows.
>> For VC, which version?
> The code in the original post compiles in VC2008SP1.

I think that 'A::A' is the same as 'A' outside of 'A', so when you write

A::A();

it's the same as to write

A();

if you're not inside the 'A' class itself (not inside of one of its
member functions). Try writing

A::A::A::A::A::A::A::A::A();

and see what happens. :-)

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 4 of 8 ==
Date: Tues, Apr 28 2009 6:24 am
From: goodbyeera@gmail.com


> > class A {};
> > int main()
> > {
> >     A::A();
> > }
> > Is this syntactically legal in standard C++?
>
> Yes, AFAIK (regarding the qualification with A::, but check the standard if it
> matters). It constructs a temporary of type A.
I can't find a direct answer from the standard whether this syntax is
legal or not. And FYI, Comeau doesn't compile this code.

> > And even more, the following code compiles in g++ (but not in vc).
> > #include <typeinfo>
> > class A {};
> > int main()
> > {
> >     typeid(A::A);
> > }
> > What does this mean?
>
> typeid is a built-in operator.
typeid should take an expression or a type as its operand, but I don't
know what kind of expression or type A::A represents.


== 5 of 8 ==
Date: Tues, Apr 28 2009 6:27 am
From: Victor Bazarov


goodbyeera@gmail.com wrote:
>>> class A {};
>>> int main()
>>> {
>>> A::A();
>>> }
>>> Is this syntactically legal in standard C++?
>> Yes, AFAIK (regarding the qualification with A::, but check the standard if it
>> matters). It constructs a temporary of type A.
> I can't find a direct answer from the standard whether this syntax is
> legal or not. And FYI, Comeau doesn't compile this code.
>
>>> And even more, the following code compiles in g++ (but not in vc).
>>> #include <typeinfo>
>>> class A {};
>>> int main()
>>> {
>>> typeid(A::A);
>>> }
>>> What does this mean?
>> typeid is a built-in operator.
> typeid should take an expression or a type as its operand, but I don't
> know what kind of expression or type A::A represents.

Every class has a name of itself injected into its scope. So, 'A::'
resolves to the scope of the class A, and the name 'A' in that scope
refers to the class itself, recursively. 'A::A::A::A::A::A ...' is the
same as 'A', but only outside of the class itself, IIRC.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 6 of 8 ==
Date: Tues, Apr 28 2009 6:29 am
From: goodbyeera@gmail.com


> I think that 'A::A' is the same as 'A' outside of 'A', so when you write
>     A::A();
> it's the same as to write
>     A();
> if you're not inside the 'A' class itself (not inside of one of its
> member functions).  Try writing
>     A::A::A::A::A::A::A::A::A();
> and see what happens. :-)
I see what you mean. Is this compliant with C++ standard? Coz
neither VC nor Comeau compiles this code.


== 7 of 8 ==
Date: Tues, Apr 28 2009 6:31 am
From: Victor Bazarov


goodbyeera@gmail.com wrote:
>> I think that 'A::A' is the same as 'A' outside of 'A', so when you write
>> A::A();
>> it's the same as to write
>> A();
>> if you're not inside the 'A' class itself (not inside of one of its
>> member functions). Try writing
>> A::A::A::A::A::A::A::A::A();
>> and see what happens. :-)
> I see what you mean. Is this compliant with C++ standard? Coz
> neither VC nor Comeau compiles this code.

Maybe I got it backwards and it's only allowed inside the class scope...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 8 of 8 ==
Date: Tues, Apr 28 2009 6:35 am
From: goodbyeera@gmail.com


On Apr 28, 9:31 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> goodbye...@gmail.com wrote:
> >> I think that 'A::A' is the same as 'A' outside of 'A', so when you write
> >>     A::A();
> >> it's the same as to write
> >>     A();
> >> if you're not inside the 'A' class itself (not inside of one of its
> >> member functions).  Try writing
> >>     A::A::A::A::A::A::A::A::A();
> >> and see what happens. :-)
> > I see what you mean.  Is this compliant with C++ standard?  Coz
> > neither VC nor Comeau compiles this code.
>
> Maybe I got it backwards and it's only allowed inside the class scope...
In g++, it's allowed inside both inside and outside class scope. In
VC and Comeau, it's not allowed in either scope.

==============================================================================
TOPIC: C++ is complicated
http://groups.google.com/group/comp.lang.c++/t/ec94a39f632a6c05?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Apr 28 2009 6:05 am
From: Jeff Schwab


namekuseijin wrote:
> Matthias Buelow wrote:
>> Juha Nieminen wrote:
>>> I thought Lisp has always been nothing but a functional language.
>>
>> Mainstream dialects have always had assignment and destructive
>> operations.
>
> The only purely functional language I'm aware of is Haskell (and perhaps
> Miranda, its direct predecessor). ML, OCaml, Common Lisp, Scheme and
> Erlang all incorporate non-lazy semantics and direct imperative
> constructs, though some use more than others.

In what way do "non-lazy semantics" prevent something being a functional
programming language? My understanding is that any language in which
all data are immutable is inherently "purely functional." If that
understanding is flawed, please post a link to a more formal definition.

> Scheme and ML are very purist languages.

I thought Scheme was meant to be a purely functional version of Lisp.
Did you just say it isn't purely functional, though?


== 2 of 3 ==
Date: Tues, Apr 28 2009 7:54 am
From: "Tony"

"Jerry Coffin" <jcoffin@taeus.com> wrote in message
news:MPG.245f907350914cc79896ef@news.sunsite.dk...
> In article <6ODIl.6100$Lr6.1056@flpi143.ffdc.sbc.com>, tony@my.net
> says...

>> The question becomes, "what is the *simple solution* that will surface
>> after
>> concepts?".
>
> I doubt that question has much relevance. Even if you could figure out
> what language features (and such) were going to be used, say, 50 years
> from now, I doubt it'd be much use. Trying to use that future language
> on current hardware would be a bit like trying to run a current C++
> compiler on an Apple II+ with 32K of RAM and 140K floppy disks.

Programming languages will become simpler rather than more bloated because
of the abundance of processing power available (primary and secondary
storage too), at least for the majority of mainstream programming (whatever
that is ;) ). Exotic languages and techniques will be for the exceptional
cases and specialized environments. More emphasis will be placed on what is
adequate for the application and platform and how simply can it be
implemented (including how "simple" the libraries and language are in use
and implementation) rather than such esoteric things as container
performance when it wouldn't matter for the application even if an algorithm
was 30 times slower. Comprehensible and maintainable design (and other
things) will be more important that benchmarks. This is not that far off
into the future. (More observable in new development where there is not
existing codebase and infrastructure holding back progress toward
historically unrealized elegance).


== 3 of 3 ==
Date: Tues, Apr 28 2009 9:27 am
From: namekuseijin


Jeff Schwab escreveu:
> namekuseijin wrote:
>> Matthias Buelow wrote:
>>> Juha Nieminen wrote:
>>>> I thought Lisp has always been nothing but a functional language.
>>>
>>> Mainstream dialects have always had assignment and destructive
>>> operations.
>>
>> The only purely functional language I'm aware of is Haskell (and
>> perhaps Miranda, its direct predecessor). ML, OCaml, Common Lisp,
>> Scheme and Erlang all incorporate non-lazy semantics and direct
>> imperative constructs, though some use more than others.
>
> In what way do "non-lazy semantics" prevent something being a functional
> programming language?

In no way. It just won't ever be *purely* functional, since pure
functions don't ever yield side-effects.

> My understanding is that any language in which
> all data are immutable is inherently "purely functional." If that
> understanding is flawed, please post a link to a more formal definition.

Purely functional means referential transparency: you may use the
substituition model of evaluation to reduce the computations. You can't
use that model with full Scheme, because the language standard provides
assignment operations and the substitution model no longer works in the
presence of mutable state.

I refer you to:
http://mitpress.mit.edu/sicp/full-text/book/book.html

in particular:
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html#%_sec_1.1.5
and
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-20.html#%_sec_3.1.3

A classic and excellent book, BTW.

>> Scheme and ML are very purist languages.
>
> I thought Scheme was meant to be a purely functional version of Lisp.
> Did you just say it isn't purely functional, though?

It isn't purely functional. It's just a simpler, cleaner Lisp. Lisp
the way it ought to be, IMO.

--
a game sig: http://tinyurl.com/d3rxz9

==============================================================================
TOPIC: Ascii Characters
http://groups.google.com/group/comp.lang.c++/t/b426276abbbce135?hl=en
==============================================================================

== 1 of 6 ==
Date: Tues, Apr 28 2009 6:13 am
From: e4me4m@gmail.com


This is a very dumb question... I have a std::vector<std::string> that
I'm pushing ascii charcters into like so:

set.push_back("a");
set.push_back("b");
...
...

I'm doing this manually. This is error prone and time consuming. Does
something in the STL have these already? I'm rather new to C++ so
forgive me if this is blatantly obvious. Google did not help much. The
goal is to get all typable ascii chars into the vector.

Thanks


== 2 of 6 ==
Date: Tues, Apr 28 2009 6:19 am
From: Victor Bazarov


e4me4m@gmail.com wrote:
> This is a very dumb question... I have a std::vector<std::string> that
> I'm pushing ascii charcters into like so:
>
> set.push_back("a");
> set.push_back("b");

'set' is not the best name for a vector. There is 'std::set', you know...

> ...
> ...
>
> I'm doing this manually. This is error prone and time consuming. Does
> something in the STL have these already? I'm rather new to C++ so
> forgive me if this is blatantly obvious. Google did not help much. The
> goal is to get all typable ascii chars into the vector.

I am not sure what is "a typable ascii", to be honest, perhaps you need
to do 'isprint' on those, but look into 'std::generate' or 'std::fill'.
There is a constructor of 'std::string' that takes the value and the
count, use it in a loop. Something like

for (char c = ' '; c <= '~'; ++c)
set.push_back(std::string(1, c));

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 3 of 6 ==
Date: Tues, Apr 28 2009 6:44 am
From: pjb@informatimago.com (Pascal J. Bourguignon)


e4me4m@gmail.com writes:

> This is a very dumb question... I have a std::vector<std::string> that
> I'm pushing ascii charcters into like so:
>
> set.push_back("a");
> set.push_back("b");
> ...
>
> I'm doing this manually. This is error prone and time consuming. Does
> something in the STL have these already? I'm rather new to C++ so
> forgive me if this is blatantly obvious. Google did not help much. The
> goal is to get all typable ascii chars into the vector.

Better browse directly a C++ Library Reference such as
http://www.cplusplus.com/reference/


std::string printableCharactersInASCII(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");

for(std::string::const_iterator it=printableCharactersInASCII.begin();
it!=printableCharactersInASCII.end();
it++){
std::string character(it,it+1);
set.push_back(character);
}

Notice that this program works even on systems that don't use the
ASCII _code_, as long as they can represent all the printable
characters of the ASCII _character_ _set_ (those in that
printableCharactersInASCII string).


--
__Pascal Bourguignon__


== 4 of 6 ==
Date: Tues, Apr 28 2009 6:44 am
From: pjb@informatimago.com (Pascal J. Bourguignon)


Victor Bazarov <v.Abazarov@comAcast.net> writes:

> for (char c = ' '; c <= '~'; ++c)
> set.push_back(std::string(1, c));

This doesn't work on my EBCDIC based system. Broken program!

--
__Pascal Bourguignon__


== 5 of 6 ==
Date: Tues, Apr 28 2009 6:57 am
From: Victor Bazarov


Pascal J. Bourguignon wrote:
> Victor Bazarov <v.Abazarov@comAcast.net> writes:
>
>> for (char c = ' '; c <= '~'; ++c)
>> set.push_back(std::string(1, c));
>
> This doesn't work on my EBCDIC based system. Broken program!

Didn't the OP say "ASCII"?...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


== 6 of 6 ==
Date: Tues, Apr 28 2009 7:47 am
From: pjb@informatimago.com (Pascal J. Bourguignon)


Victor Bazarov <v.Abazarov@comAcast.net> writes:

> Pascal J. Bourguignon wrote:
>> Victor Bazarov <v.Abazarov@comAcast.net> writes:
>>
>>> for (char c = ' '; c <= '~'; ++c)
>>> set.push_back(std::string(1, c));
>>
>> This doesn't work on my EBCDIC based system. Broken program!
>
> Didn't the OP say "ASCII"?...

No, he said "the ASCII characters".

Whatever the encoding used by the programming language and/or the
host, you can handle them as long has their character set includes the
ASCII printable characters, which are the space and
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~


Unfortunately, when you use the char type in C or C++, with literals
such as ' ' or '~', you are not working with characters anymore, but
with their codes (char is a subtype of int, not of character).


We may assume that if the OP is interested by ASCII characters, he may
have to encode and decode them, so it is assumed that the
printableCharactersInASCII string will be used to do that:

#include <limits.h>
#if CHARBITS<7
typedef int ASCII_Code;
#else
typedef unsigned char ASCII_Code;

No comments: