Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compilation of Awkward Syntax

130 views
Skip to first unread message

Joe Snodgrass

unread,
Apr 27, 2013, 8:58:11 AM4/27/13
to
I've almost finished teaching myself C++, but there's one last step I
have to take. I need to teach myself all the situations that require
one to use a strange looking combination of operators.

One example of a strange looking combination of operators that I
managed to work through is

tmp=(Node<int>*)ptr,

You can see that the >* is nothing like anything that would have been
seen in any previous (or structured) language.

I seem to recall seeing this sort of awkward syntax in several
different situations, when I read 2nd edition of Stroustrup, not just
this situation.

Does anybody know if someone has assembled a cheat sheet to pull them
all together in one place? TIA.
Message has been deleted

Alain Ketterlin

unread,
Apr 27, 2013, 9:23:14 AM4/27/13
to
Joe Snodgrass <vaughan....@gmail.com> writes:

> I've almost finished teaching myself C++, but there's one last step I
> have to take. I need to teach myself all the situations that require
> one to use a strange looking combination of operators.
>
> One example of a strange looking combination of operators that I
> managed to work through is
>
> tmp=(Node<int>*)ptr,

What exactly is strange here? It's just a type-cast.

> You can see that the >* is nothing like anything that would have been
> seen in any previous (or structured) language.

"i>*p" is perfectly correct C/C++ (provided p is a pointer to anything
that can be compared to i).

I'm not sure what you are looking for, but in any case ">*" in your
example is certainly not a "combination of operators" (whatever that
means), because that is not how this piece of text is parsed
(tokenized).

> I seem to recall seeing this sort of awkward syntax in several
> different situations, when I read 2nd edition of Stroustrup, not just
> this situation.
>
> Does anybody know if someone has assembled a cheat sheet to pull them
> all together in one place? TIA.

I must have missed something...

-- Alain.

Nobody

unread,
Apr 27, 2013, 3:29:31 PM4/27/13
to
On Sat, 27 Apr 2013 05:58:11 -0700, Joe Snodgrass wrote:

> One example of a strange looking combination of operators that I
> managed to work through is
>
> tmp=(Node<int>*)ptr,

"Node<int>" is a type, a specialisation of the Node template with int
as the parameter. Template syntax uses < and > as brackets.

"Node<int>*" is also a type, a pointer to Node<int>.

"(Node<int>*)ptr" is a cast of ptr to the type Node<int>*.


osmium

unread,
Apr 27, 2013, 3:41:14 PM4/27/13
to
Perhaps what the OP could use is a C++ variant of "cdecl"; If there is none
it might be an interesting problem for someone looking for something to test
himself with.


Tony

unread,
Apr 28, 2013, 5:55:00 AM4/28/13
to
In article <cac6d15b-70d9-46a1...@b20g2000yqo.googlegroups.com>,
vaughan....@gmail.com says...
>
> I've almost finished teaching myself C++

How long did it take you from start to finish?

Joe Snodgrass

unread,
May 1, 2013, 5:54:08 PM5/1/13
to
On Apr 28, 5:55 am, Tony <a...@some.org> wrote:
> In article <cac6d15b-70d9-46a1-abae-db017b5d3...@b20g2000yqo.googlegroups.com>,
> vaughan.andur...@gmail.com says...
>
> > I've almost finished teaching myself C++
>
> How long did it take you from start to finish?

Three months. Why do you ask?
Message has been deleted

Balog Pal

unread,
May 1, 2013, 8:46:12 PM5/1/13
to
On 5/2/2013 12:52 AM, Stefan Ram wrote:
> Can you explain:
>
> - argument-dependent lookup
> - SFINAE
> - RAII
> - RVO
> - COW
> - the rule of the three (today, also: five/zero)
> - how to do exception-safe programming
> - when should an operator be defined as a member?
> - what is a scope guard?
> - what is a good example of when to use a variadic
> template?
> - What is the copy-and-swap idiom
> - When to use "const", when "constexpr"?
> - Does C++ have 2 dimensional arrays?
> - When to use "auto" vs when to use a specific type?
> - the difference between operator new and the new
> operator?
> - the difference between member constants and constant
> members?
> - how to implement the factorial using template
> metaprogramming
> - type traits
> - what algorithms are provided in the standard
> library (header <algorithm>)
> - CRTP - Curiously Recurring Template Pattern
> - What smart pointers are provided by the standard
> library, and when to use them?
> - Functors
> - policy-based design
> - reinterpret_cast, dynamic_cast
> - is the expression "a=2" an lvalue or an rvalue?
> - move semantics
> - perfect forwarding
> - RTTI
> - type erasure
> - when to use "typename"
> - What is �C++'s most vexing parse�?
> - What is the difference between �int a=2;�,
> �int a(2);� and �int a{2};�?
>
> And this is just what immediately popped into my head,
> but there is still much more to learn!

Great list. When someone comes ahead as "I know C++" or claim to be
expert, my first reaction is "wow, then please explain me the two phase
lookup please". An if still around, to tell me the rules to select the
overload for foo(a, b) if we have certain types for a and b (including
variants with cv qualificaitons and refs and possible inplicit
conversions to other types), while foo is an overload set having
functions, templates, specialisations sitting in various namespaces.

(btw what I consider the full-score answer for the latter is "if you
have a proper overload set, then you should not care what is picked as
long as it compiles, and if the answer actually matters you are already
in trouble.)






Tony

unread,
May 1, 2013, 11:41:43 PM5/1/13
to
In article <8c80b870-c9cb-449a...@g9g2000yqh.googlegroups.com>,
vaughan....@gmail.com says...
Because becoming a master of C++ takes years and I'm wondering what the actual
number is on average. You said you were "almost done" learning C++. (I missed
the 'almost' when I posted, but the question is still valid).

Tobias Müller

unread,
May 2, 2013, 2:07:33 AM5/2/13
to
Tony <a...@some.org> wrote:
> In article <8c80b870-c9cb-449a...@g9g2000yqh.googlegroups.com>,
> vaughan....@gmail.com says...
>>
>> On Apr 28, 5:55 am, Tony <a...@some.org> wrote:
>>> In article <cac6d15b-70d9-46a1-abae-db017b5d3...@b20g2000yqo.googlegroups.com>,
>>> vaughan.andur...@gmail.com says...
>>>
>>>> I've almost finished teaching myself C++
>>>
>>> How long did it take you from start to finish?
>>
>> Three months. Why do you ask?
>
> Because becoming a master of C++ takes years and I'm wondering what the actual
> number is on average. You said you were "almost done" learning C++. (I missed
> the 'almost' when I posted, but the question is still valid).

At some point you have to stop learning (in the sense of guided learning,
reading books and solving toy exercises) and start gaining experience with
real programs.

Of course you will still have to consult a book every now and then. If you
have a mentor who can help you, even better.

But you won't become a master if you never start using the language.

Tobi

Andy Champ

unread,
May 2, 2013, 4:00:35 AM5/2/13
to
On 01/05/2013 23:52, Stefan Ram wrote:
> And this is just what immediately popped into my head,
> but there is still much more to learn!

There's always more to learn. Move semantics, for example, weren't there
until recently and I haven't had to use them yet...

Andy

Tony

unread,
May 2, 2013, 5:35:27 AM5/2/13
to
In article <140766362389166631.22...@news.eternal-
september.org>, tro...@bluewin.ch says...
I started in the early 1990's. As I tend to avoid some of the language (I subset
it), I probably wouldn't score well on a test of the more esoteric "features",
and certainly being employed as a C++ programmer (again) is definitely not
something I would entertain.

Bo Persson

unread,
May 2, 2013, 12:57:01 PM5/2/13
to
Twenty years, so far. I'll tell you when I'm done.


The fun part is that when asked the classic question

"On a scale from 1-10, where Bjarne Stroustrup is a 10, how well do you
know C++?",

the answer is often 9 after 3 months, 8 after a year, and 7 after 5
years. I'm now probably down to 5 or 6.

And I guess Bjarne isn't at 10 either. :-)


Bo Persson

Message has been deleted

James Kanze

unread,
May 2, 2013, 2:07:46 PM5/2/13
to
For what definition of master? What do you want to do with C++?
I'd say that with proper mentoring, an average person can learn
it sufficiently for most jobs in about six months. A gifted
person can learn it well enough to write a compiler for it in
about a year.

Of course, since it's not a dead language, you always have to
keep abreast. The C++ we write today isn't the C++ I learned 20
years ago.

--
James

88888 Dihedral

unread,
May 2, 2013, 4:04:04 PM5/2/13
to
Tony於 2013年5月2日星期四UTC+8上午11時41分43秒寫道:
> > On Apr 28, 5:55 am, Tony wrote:
>
> > > In article ,
>
> > > vaughan.andur...@gmail.com says...
>
> > >
>
> > > > I've almost finished teaching myself C++
>
> > >
>
> > > How long did it take you from start to finish?
>
> >
>
> > Three months. Why do you ask?
>
>
>
> Because becoming a master of C++ takes years and I'm wondering what the actual
>
> number is on average. You said you were "almost done" learning C++. (I missed
>
> the 'almost' when I posted, but the question is still valid).

In C++ the object part, the name space of using objects or
functions from some other library, and the template part
are all static linked in the compile time except those
objects use virtual methods inside a loop.

I'll assume that you are not using an interpreter embedded with
your C++ programs.

Also the vector part does boundary checking all the time
just like the old Fortran way but not the notorious
C-assembly way.

Tony

unread,
May 3, 2013, 12:04:38 AM5/3/13
to
In article <5f167375-6347-4ecc...@googlegroups.com>,
james...@gmail.com says...
>
> On Thursday, 2 May 2013 04:41:43 UTC+1, Tony wrote:
> > In article <8c80b870-c9cb-449a...@g9g2000yqh.googlegroups.com>,
> > vaughan....@gmail.com says...
> > >
> > > On Apr 28, 5:55 am, Tony <a...@some.org> wrote:
> > > > In article <cac6d15b-70d9-46a1-abae-db017b5d3...@b20g2000yqo.googlegroups.com>,
> > > > vaughan.andur...@gmail.com says...
> > > >
> > > > > I've almost finished teaching myself C++
> > > >
> > > > How long did it take you from start to finish?
> > >
> > > Three months. Why do you ask?
> >
> > Because becoming a master of C++ takes years and I'm wondering
> > what the actual number is on average. You said you were
> > "almost done" learning C++. (I missed the 'almost' when
> > I posted, but the question is still valid).
>
> For what definition of master? What do you want to do with C++?
> I'd say that with proper mentoring, an average person can learn
> it sufficiently for most jobs in about six months.

By any definition of "master". What you wrote above seems to fit right in with
your "all the expressivity of C++" BS, in that, now you're trying to make it
seem like C++ is easy to master? Pfft. I'd say, that you cannot have a real C++
programmer with less than 5 years from the start of using it. Secondly, I
theorize that USE TIME is not as important as THINK TIME, especially in the
initial years. It's just that complex, intricate, subtle, etc. How do I know?
I've been there, done that. Blind-usage/trained-monkey-usage of it is to fall
prey to the spiel. You end up with a highly-proficient-C++-programmer, that
can't program himself out of a paper bag without millions of lines of esoteric
C++. Now, if that programmer was actually a good one, he would step out of the
fog of C++ and realize that a simple and elegant solution could be had save for
C++ not being able to render along those constraints.

So somewhere during journeyman path, the programmer on the "C++ master"
direction begins building all kinds of libraries (the preprocessor not
withstanding) until a light bulb moment arrives and that programmer realizes
that it's futile endeavor.

Of course the "programmer" in my text above is actually a frustrated (with C++)
SOFTWARE DEVELOPER. Big difference. A "programmer" is one of those who code
under the direction of "a C++ master", the "master" part here taking on a whole
new context. They buy into the spiel like young men enlisting in the army "for
real good reason".

Am I digressing again? Anyway, you get my drift.


> A gifted
> person can learn it well enough to write a compiler for it in
> about a year.

And what "gift" would that person possess, pray tell.

>
> Of course, since it's not a dead language, you always have to
> keep abreast. The C++ we write today isn't the C++ I learned 20
> years ago.

Nor is it the one I abandoned years ago, and it's not like building more
scaffolding has made it any better OVERALL than it was back then. An appropriate
metaphor may be that it has a lot of momentum, but two tons of moving garbage
has more momentum than one ton of it, so more is not better.


Tony

unread,
May 3, 2013, 12:10:02 AM5/3/13
to
In article <aufk6q...@mid.individual.net>, b...@gmb.dk says...
I like that. (I know, everyone is saying, "duh, we know YOU would!"). I've been
down that road, reached 0 and wrapped around to 255 (at least no one can call me
a 2-bit (unsigned) int!). :)

Quiz for the day: What is an "int wit"?

Andy Champ

unread,
May 3, 2013, 5:23:20 AM5/3/13
to
On 02/05/2013 18:04, Stefan Ram wrote:
> Bo Persson <b...@gmb.dk> writes:
>> "On a scale from 1-10, where Bjarne Stroustrup is a 10, how well do you
>> know C++?",
>
> http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
>

I've been asked to rate myself on a scale of 1-5, and said 5. I'm quite
happy to put myself in the top 20%.

I'm also aware that there are a number of people - several in this very
group - who are a lot better than I am. I look on the skills as being
something like a poisson distribution - there are a small number of very
highly skilled people.

Andy

James Kanze

unread,
May 3, 2013, 11:39:16 AM5/3/13
to
On Friday, 3 May 2013 05:04:38 UTC+1, Tony wrote:
> In article <5f167375-6347-4ecc...@googlegroups.com>,
> james...@gmail.com says...

> Pfft. I'd say, that you cannot have a real C++
> programmer with less than 5 years from the start of using it.

Then you're wrong, because I regularly see competent programmers
learn it in about six months. Not well enough to write
a compiler for it, but well enough to be efficiently productive
in our application code.

--
James

Joe Snodgrass

unread,
May 3, 2013, 9:50:20 PM5/3/13
to
On May 1, 6:52 pm, r...@zedat.fu-berlin.de (Stefan Ram) wrote:
>   He might suspect that it might be a case of »It took 90 % of
>   the time to learn to first 90 % and it will take 90 % of the
>   time to learn the next 9 %.« (The other 90 % then will be
>   needed for the next 0.9 %.)
>   And this is just what immediately popped into my head,
>   but there is still much more to learn!

Any time you feel like showing off your exemplary knowledge by posting
extensive lists like that one, you just go right ahead. You're doing
me a big fat juicy favor by itemizing the advanced topics I'm now
ready to study. Please make the list as exhaustive as you possibly
can, so I can begin ticking items off it, starting the moment you post
it. The harder you can make it, the better, because I LIVE FOR THE
CHALLENGE!!

Jorgen Grahn

unread,
May 4, 2013, 12:14:05 AM5/4/13
to
But I suppose after 3 months, a year, 5 years, you worry less and less
about it.

Personally I feel the subset of C++ (or C++98) I know is enough, in
the sense that I can read all code I need to read, and I can express
the things I need to express efficiently in my own code. (Or at least,
that the things I cannot express elegantly couldn't be fixed using the
parts of the language I /don't/ know well.)

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Balog Pal

unread,
May 5, 2013, 8:49:22 AM5/5/13
to
But I guess they had live access to a good C++ mentor during the
learning process and an environment doing C++ code and regular reviews.

That's hardly a condition trivial to meet.


Jorgen Grahn

unread,
May 5, 2013, 11:04:48 AM5/5/13
to
On Sun, 2013-05-05, Balog Pal wrote:
> On 5/3/2013 5:39 PM, James Kanze wrote:
>> On Friday, 3 May 2013 05:04:38 UTC+1, Tony wrote:
>>> In article <5f167375-6347-4ecc...@googlegroups.com>,
>>> james...@gmail.com says...
>>
>>> Pfft. I'd say, that you cannot have a real C++
>>> programmer with less than 5 years from the start of using it.
>>
>> Then you're wrong, because I regularly see competent programmers
>> learn it in about six months. Not well enough to write
>> a compiler for it, but well enough to be efficiently productive
>> in our application code.

That "in our application code" is important -- it gets much easier if
the architecture is already there, and the subset of the language is
fixed.

> But I guess they had live access to a good C++ mentor during the
> learning process and an environment doing C++ code and regular reviews.
>
> That's hardly a condition trivial to meet.

Not /trivial/, but surely not unusual either? Anyone joining a team
working with C++ would meet it. (Unless the team don't know C++, or
are openly hostile to newcomers.)

Learning as an isolated hobby user is much harder. But that goes for
any language.

Tony

unread,
May 6, 2013, 3:39:36 AM5/6/13
to
In article <c512d5c1-784f-48c9...@googlegroups.com>,
james...@gmail.com says...
I'm not saying you are worthless or what you have done is worthless, I'm just
trying to keep you away from youth. I didn't mean that. I mean, if anyone is
going to actually FOLLOW you, c'mon, wouldn't I be the one to punch you in the
face for that?

I don't want to fight you. That's what you do though? Who are you? Who must bow
to you? How much money do you want? What went wrong? What's your price to make
you happy? (rhetorical)

Tony

unread,
May 6, 2013, 3:39:37 AM5/6/13
to
In article <krGdnSNt-52bHx7M...@eclipse.net.uk>,
no....@nospam.invalid says...
>
> On 02/05/2013 18:04, Stefan Ram wrote:
> > Bo Persson <b...@gmb.dk> writes:
> >> "On a scale from 1-10, where Bjarne Stroustrup is a 10, how well do you
> >> know C++?",
> >
> > http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
> >
>
> I've been asked to rate myself on a scale of 1-5, and said 5. I'm quite
> happy to put myself in the top 20%.

The top 20% of what?

>
> I'm also aware that there are a number of people - several in this very
> group - who are a lot better than I am.

Better at what?

> I look on the skills as being
> something like a poisson distribution

poison?

> - there are a small number of very
> highly skilled people.

Ya think? Were you suggesting "skilled in your shit"? Hmm?

Stuart

unread,
May 7, 2013, 2:33:36 AM5/7/13
to
On 05/05/13, Jorgen Grahn wrote:
> Learning [C++ (added by Stuart)] as an isolated hobby user is much harder. But that goes for
> any language.

+1

I once met a guy that got a student's jobs at the Fraunhofer Institute
and got _paid_ half a year's wages just to learn how to program C++. I
was a bit jealous because when I got a students job at the same
department I had to program C++ right away, even though I had never used
it before either. But as a major in CS, I was supposed to know C++ (as
if studying CS meant that one would learn all the programming languages
in the world), while this guy majored in mathematics.

But the important point is: Learning C++ as an isolated hobby user is
IMHO also futile. There is so much of it to learn that one has to spend
a life-time and a half in order to learn it all.

I have seen a lot of people in newsgroups who think that learning every
aspect of C++ will score them a good job. I think they're wrong. The
same guy that got paid for learning C++ at Fraunhofer Institute once
told me what studying mathematics is actually about: Showing that you
can conquer any problem - no matter how boring, no matter how
complicated - that is thrown at you. That are the skills that are most
important for good programmers: analytical thinking and the ability to
abstract things.

Regards,
Stuart
0 new messages