comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* Reference is not an object. - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/76b508a8b70ab612?hl=en
* Template to add members to a class - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/4093d20b1f2e8f1a?hl=en
* Good way to write integer overflow checks? - 19 messages, 9 authors
http://groups.google.com/group/comp.lang.c++/t/1363de0ff88836cd?hl=en
* WHAT DOES ISLAM SAY ABOUT TERRORISM ????????????????? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/6bd3b1012d72d85b?hl=en
==============================================================================
TOPIC: Reference is not an object.
http://groups.google.com/group/comp.lang.c++/t/76b508a8b70ab612?hl=en
==============================================================================
== 1 of 3 ==
Date: Mon, Nov 11 2013 5:23 pm
From: wy
On 11/11/2013 09:18 AM, Ian Collins wrote:
> int &r = ref;
>
> doesn't declare a reference to a reference, it declares another
> reference that is assigned the same value as ref.
I say this on P69 of the book. "When we use a reference, we are really
using the object to which the reference refers." Thank you!
> int& *p;
>
> would attempt to declare a pointer to a reference.
>
So "int &&" attempts to declare a reference to a reference, "int &*"
attempts to declare a pointer to a reference, right?
== 2 of 3 ==
Date: Mon, Nov 11 2013 6:10 pm
From: Öö Tiib
On Tuesday, 12 November 2013 03:23:40 UTC+2, wy wrote:
> On 11/11/2013 09:18 AM, Ian Collins wrote:
> > int &r = ref;
> >
> > doesn't declare a reference to a reference, it declares another
> > reference that is assigned the same value as ref.
> I say this on P69 of the book. "When we use a reference, we are really
> using the object to which the reference refers." Thank you!
>
> > int& *p;
> >
> > would attempt to declare a pointer to a reference.
> >
>
> So "int &&" attempts to declare a reference to a reference, "int &*"
> attempts to declare a pointer to a reference, right?
No. "int &&" is reference to int rvalue. "int &*" is syntax error
that looks like someone wanted to declare pointer to reference.
== 3 of 3 ==
Date: Tues, Nov 12 2013 4:07 am
From: sg
Am 12.11.2013 02:23, schrieb wy:
> So "int &&" attempts to declare a reference to a reference,
No. Careful. && is a single token. What you should have written is:
int & &
with a space in between the ampersands. But since this doesn't work
anyways, you can just forget about it. :)
Starting with C++11 the double-ampersand (as single token) can also be
used to declare a reference. It's another kind of reference:
int & lvalue reference to int
int && rvalue reference to int (NOT a ref to a ref!)
> "int &*" attempts to declare a pointer to a reference, right?
Yes. But this also does not work, because a reference it not an object.
You can only create pointers to objects or pointers to functions.
==============================================================================
TOPIC: Template to add members to a class
http://groups.google.com/group/comp.lang.c++/t/4093d20b1f2e8f1a?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Nov 12 2013 12:01 am
From: Juha Nieminen
Giuliano Bertoletti <gbe32241@libero.it> wrote:
> I need to define other classes with the same layout but with generally a
> different number of items.
It sounds like you essentially want std::tuple.
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
== 2 of 3 ==
Date: Tues, Nov 12 2013 2:23 am
From: James Kanze
On Monday, 11 November 2013 19:30:24 UTC, David Harmon wrote:
> On Sun, 10 Nov 2013 12:02:20 +0100 in comp.lang.c++, "Alf P.
> Steinbach" <alf.p.steinbach+usenet@gmail.com> wrote,
> >The prefix "C" for a class is a Microsoft abomination.
> >It has no useful purpose, but it does preclude using that prefix to
> >indicate something useful such as "const".
> It serves the very useful purpose of enabling someone reading your
> code to distinguish Microsoft classes from your own classes without
> remembering them all. Never using class names beginning with "C"
> for your own classes is a small price to pay for that. Of course
> namespaces are a better solution, but many Microsoft APIs were
> defined before c++ namespaces existed.
It's fairly short for a prefix. Still, it doesn't exclude using
your own classes beginning with a "C", as long as the "C" isn't
a prefix in your classes. In the Microsoft classes, it will be
a "C", followed by a word which also begins with an upper case;
it's immediately visible that the "C" is a prefix. In your own
classes, if the "C" isn't a prefix, it will normally be followed
by a lower case, and will effectively appear as part of the
name, and not an unrelated prefix.
--
James
== 3 of 3 ==
Date: Tues, Nov 12 2013 3:44 am
From: Öö Tiib
On Sunday, 10 November 2013 10:34:10 UTC+2, Giuliano Bertoletti wrote:
> I've some classes with the following layout:
>
> // CCrumb is a string derived type
>
> typedef std::vector<CCrumb *> CRUMBSVECTOR;
>
> class CMatchEntry {
> public:
> // similar classes may have a different number of CCrumbs
> // with different names
> CCrumb id;
> CCrumb name;
> CCrumb logistic;
> CCrumb result;
> CCrumb details;
> CCrumb status;
>
> public:
> // there's only this member which
> // fills a vector of pointers
> void GetCrumbs(CRUMBSVECTOR &cv)
> {
> cv.clear();
> cv.push_back(&id);
> cv.push_back(&name);
> cv.push_back(&logistic);
> cv.push_back(&result);
> cv.push_back(&details);
> cv.push_back(&status);
> }
> };
>
> as you see, this class has some members all of the same type which have
> to be conveniently returned into a vecotr of pointers for output in an
> HTML table.
>
> I need to define other classes with the same layout but with generally a
> different number of items.
When I generate classes then I usually do it with some (often self-made) external
code generator tool. Preprocessor metaprogramming and/or template
metaprogramming feel hellishly cryptic if to compare with little Python script that
any kid can read.
> I do not want to define a vector of crumbs inside a generic class,
> beacuse I would then need to use indexes to set members which is prone
> to error.
>
> Is there a way to cleverly use template and define classes by specifying
> only the names and number of crumbs? I.e.
Ok ... so hard way then? Smart choice. Boost.Serialization can serialise any
object to XML and back from XML to object with not too much work for user.
Writing similar thing is another story of course. ;-) Download it and study.
Every preprocessor, template and pointer-to-member trick you need (and
way more than you need) is used there. You are lot more clever after
studying it than you were before. ;-)
==============================================================================
TOPIC: Good way to write integer overflow checks?
http://groups.google.com/group/comp.lang.c++/t/1363de0ff88836cd?hl=en
==============================================================================
== 1 of 19 ==
Date: Tues, Nov 12 2013 1:02 am
From: David Brown
On 11/11/13 19:47, Leigh Johnston wrote:
> On 11/11/2013 12:42, David Brown wrote:
>> On 11/11/13 12:31, Alf P. Steinbach wrote:
>>> On 11.11.2013 09:29, David Brown wrote:
>>>> On 09/11/13 22:00, Alf P. Steinbach wrote:
>>>
>>> I'm sorry but what you write sounds like trolling. It's certainly
>>> idiocy, it's certainly more about your guessing about people's thoughts
>>> than the technical, and your assertions are extremely dishonest.
>>>
>>> I.e. you're a liar.
>>>
>>> Plink.
>>>
>>> - Alf
>>>
>>
>> If you disagree with what I write, then point out the mistakes. If I am
>> wrong to assume you are merely guessing about compiler behaviour, then
>> show me the appropriate disassembly proving that you /have/ tested this
>> properly.
>>
>> It's fine to tell me I'm rude (I'm sure there are others that will agree
>> with you), and it's fine to say I'm wrong (it would not be the first
>> time). But it is /not/ fine to accuse someone of active dishonesty and
>> lying without /very/ clear and specific evidence.
>
> The idiot "plink'd" you which is idiot-speak for blacklisting your
> posts. He has also "plink'd" me as the guy can't handle criticism.
>
> /Leigh
>
Yes, I know what he meant by "plink" (even though I have only ever seen
it as "plonk" from other Usenet users). I've always thought it was
quite childish (like putting your fingers in your ears and saying "I'm
not listening"), except of course for the worst spammers. I suppose in
the "old days" with slow links, it might have been more important to
save bandwidth.
This is a public arena - the disagreements were in public, so I think it
is right to respond in public even after a "plonk" (or "plink"). Of
course, I'd much rather that Alf reads my posts and responds - but
that's up to him.
== 2 of 19 ==
Date: Tues, Nov 12 2013 1:53 am
From: David Brown
On 11/11/13 17:07, Victor Bazarov wrote:
> On 11/11/2013 8:45 AM, David Brown wrote:
>> On 11/11/13 14:00, Victor Bazarov wrote:
>>> On 11/11/2013 7:34 AM, David Brown wrote:
>>>> On 11/11/13 12:35, Alf P. Steinbach wrote:
>>>>> On 11.11.2013 10:27, David Brown wrote:
>>>>>>
>>>>> [snipped lots of idiocy, then:]
>>>>>>
>>>>>> Oh, and "int(-1/2u)" is undefined behaviour.
>>>>>
>>>>> No, unsigned arithmetic is well-defined.
>>>>
>>>> AFAIUI, int(-1/2u) means "take the signed int -1, promote it to an
>>>> unsigned to be compatible with 2u (this promotion is UB for a negative
>>>> number),
>>>
>>> Where did you get the UB portion of that? And it's not "promoted", it's
>>> "converted". Promotions defined in [conv.prom] and they don't involve
>>> 'int' as the *source* type.
>>>
>>
>> I've read the section of the standard document, and I stand corrected -
>> thanks.
>>
>> The "-1" is converted, rather than promoted, to "unsigned int" - and
>> that conversion is done modulo 2^n. So the conversion of -1 to
>> "unsigned int" is well defined.
>>
>>>> divide it by 2 (fine in unsigned), then convert it to a signed
>>>> int (fine if there is no overflow)".
>>>
>>> "Fine" is not a definition of what's going to happen. It's
>>> implementation-defined if the value cannot be represented in the
>>> destination type. See [conv.integral].
>>
>> By "fine", I mean there is clearly defined behaviour for converting an
>> "unsigned int" into an "int" as long as there is no overflow - i.e., the
>> value can be represented identically as an "int".
>>
>> If there /is/ an overflow (i.e., the value cannot be represented), then
>
> The term "overflow" as used by some other folks here is not the same as
> "requires more storage than can be given". I believe the use of the
> term 'overflow' relates to the situation that can be recognized by the
> processor and appropriately flagged (or trapped). It is run-time
> behavior (or situation), not hypothetical relationship between numbers
> that exists at the compile time.
I am not sure that we can make such subtle distinctions about the use of
the word "overflow" - I think it is valid to use it in either sense. As
far as I can see, there is not "official" definition in the C++ standard
(correct me if I'm wrong!), and no particular grounds for fine
differentiation. To my understanding, a calculation "overflows" if it
cannot be done while keeping the natural correspondence between the
abstract idea (such as mathematical integers) and the concrete
implementation (such as a an n-bit twos-complement number). So with
16-bit integers, 30000 + 20000 overflows - regardless of whether or not
the processor flags it.
I have been trying a simple search for the term "overflow" in N3337
(approximately the C++11 standard, but conveniently available as a free
pdf). Under 1.9 "Program execution" paragraph 9, there is a discussion
about re-arranging arithmetic by associative and commutative operations
- on targets which "produce exceptions on overflow", the compiler cannot
necessarily re-arrange the arithmetic, while on targets " in which the
results of overflows are reversible" allows them.
Under chapter 5 "Expressions", we have this:
If during the evaluation of an expression, the result is not
mathematically defined or not in the range of representable values for
its type, the behavior is undefined. [ Note: most existing
implementations of C++ ignore integer overflows. Treatment of division
by zero, forming a remainder using a zero divisor, and all floating
point exceptions vary among machines, and is usually adjustable by a
library function. — end note ]
I think that suggests "overflow" means "the result is not mathematically
defined or not in the range of representable values for its type", which
is the how I have been using the term.
>
> So, given that your use of the term "overflow" appears different from
> Alf's, I would recommend reviewing your understanding and your previous
> statements in this thread. This might help you understand the
> objections Alf had to what you had said/written.
I have tried, but I don't see it. I don't think the issue of
flagging/trapping is important in the discussion (though Alf has used
"-ftrapv" with varying success in his tests). I am very open to the
idea that our disagreement was/is due to a misunderstanding on some
particular term, but I think that we do understand each other, and we
disagree. Alf thinks that signed integers should behave as module 2^n,
that this is the "natural" behaviour (following the principle of least
surprise), and that compilers should follow that even though the
standard says signed integer overflow is undefined behaviour. I think
that there is no natural behaviour for signed integer overflow, that
modulo behaviour is as surprising as any other behaviour, and that
compilers can use the "undefined behaviour" tag to allow better
optimisations.
It is unfortunate and regrettable that the argument seems to have got
suddenly out of hand with Alf's later replies to my posts - I still do
not see where his accusations come from.
>
> According to the standard, the behavior is implementation-defined, that
> means that whatever the behavior is, it shall be documented. The result
> of such conversion *may* cause overflow (IOW allow such condition to be
> registered and programmatically recognized and acted upon), but it does
> not *need to*, nor does it *usually* happen.
Yes.
>
>> the behaviour is implementation defined. (It is a good job I didn't say
>> what I thought would happen in this case - before reading the standards
>> closely here, I would probably have said it was "undefined behaviour".)
>>
>>>
>>>> Does it mean something else to you? (It's quite possible that I've got
>>>> this wrong, but I'd prefer a better reference. Certainly "unsigned
>>>> arithmetic is well-defined" is /not/ the answer.)
>>>
>>> Well, get a copy of the Standard and ask questions after reading the
>>> relevant sections of it.
>>>
>>
>> The obvious question to ask is, did I get it right this time?
>
> I'd say, you're getting closer.
>
> V
== 3 of 19 ==
Date: Tues, Nov 12 2013 2:23 am
From: tomalak@gmail.com
On Monday, November 11, 2013 11:37:46 AM UTC, Alf P. Steinbach wrote:
> I've already replied to earlier postings of yours in this thread.
>
> You have demonstrated general incompetence, reasoning disability,
> dishonesty and trolling.
>
> Plink.
Alf,
Please refrain from this unnecessary vitriol. This is a technical forum for the discussion of technical issues, and childish insults and finger-in-ear "la la la I can't hear you" screaming is off-topic. If you wish to "plink" someone then fine, do it, but there is no need to advertise the fact to the entire group, other than to "have the last word". Shame it's not even a real word.
Let's all stick to the matter at hand.
Thanks.
== 4 of 19 ==
Date: Tues, Nov 12 2013 2:45 am
From: James Kanze
On Monday, 11 November 2013 19:24:57 UTC, Alf P. Steinbach wrote:
> On 11.11.2013 19:54, James Kanze wrote:
> > On Saturday, 9 November 2013 22:09:34 UTC, Alf P. Steinbach wrote:
> >> On 09.11.2013 22:14, Ian Collins wrote:
> >>> Alf P. Steinbach wrote:
> >>>> This code is in support of some API functionality:
> >>>> [code]
> >>>> inline
> >>>> auto can_inflate( gdi::Rect const& r, int const dx, int const dy )
> >>>> -> bool
> >>> Why do you insist on using this form rather than the sorter, more
> >>> conventional form?
> >> Uhm, the word "insist" incorrectly indicates some kind of opposition to
> >> the adoption of `auto`. ;-)
> >> Anyway, there are many good reasons, but for me the most important is a
> >> consistent visual layout:
> >> * function name at fixed place.
> >> * return type visually separated.
> > You mean like the way I've always written function definitions:
> > bool
> > can_inflate( ... )
> > {
> > }
> > The function name is always at the start of the line. Has been
> > since I learned C. (Back then, about all we had for searching
> > was grep, and "grep ^can_inflate" would always get the
> > definition, and nothing else.)
> No, with C++11 that style can no longer (in practice) yield a consistent
> layout, since in cases where the return type depends on the argument
> types one avoids a lot of complication and verbosity by using `auto`.
> For details of how bad it can be see Andrei's "min max revisited"
> article in DDJ (I leave it to the reader to google it). For example,
> even in C++11 you can NOT simply write
> template< class T >
> decltype( a*b ) mul( T a, T b )
> { return a*b; }
And you said something about avoiding complication... (Of
course, in this case the return is just T, so any decltype is
simply added verbosity. I suspect you meant for a and b to
potentially have different types, however, in which case, it
sort of makes sense. If you like implicit type conversions and
unreadable code at the client level---but that too is a long
tradition, dating back to C.)
The question is: how often is something like this relevant?
Perhaps if you're writting a very low level library, but
certainly not in application code.
> But you can write, and since you're pragmatic you will eventually write,
> template< class T >
> auto mul( T a, T b )
> -> decltype( a*b )
> { return a*b; }
(Just to be clear: I think you really mean:
template< typename T1, typename T2 >
auto mul( T1 a, T2 b )
-> decltype( a * b )
{
return a * b;
}
. Otherwise, using decltype is just added verbosity.)
> So, your currently favorite style was good for C, to the degree that a
> syntax that both the C creators and the C++ creator have described as a
> "failed experiment", can be good. It was good in that sense also for
> C++03. With C++11 it's IMHO just ungood, since it no longer covers all
> cases and thus yields an inconsistent mix of declaration styles.
It's good in the same sense that && and ||, rather than "and"
and "or" are good. It's idiomatic for the language. It's what
everyone reading the language expects.
It's also good in the sense that seeing "auto" in front of
a function triggers the reaction: here's some fancy, overly
complicated template mess. Because the ubiquitous use today is
not to use "auto", unless you need it for the decltype.
That doesn't mean that in an abstract, ideal world, something
like:
FUNCTION func( ... ) -> return_type
wouldn't be better. But this isn't an abstract, ideal world;
this is C++. And the keyword "auto" is the same as for
a variable, so it doesn't add any additional information. For
the moment, all of this is new, so best practices haven't really
been established, but generally, from what I can see so far:
"auto" should be limited to variables containing "standardized"
return values of member functions, where the type of the return
value depends on the type of object the member function was
called on. E.g.
auto iter = container.begin();
For just about anything else, it's simply additional
obfuscation.
> d>> Which means that the human eye finds it much easier to just scan through
> >> the code to find a name or note the names, or inspect return types, with
> >> no to read and analyze the text.
> > You're style makes it harder to find the return type. (I never
> > found this a problem in Modula-2, but C++ is not Modula-2.)
> Hm, I can't remember much about Modula-2 declarations.
See above.
> I do remember that good old Niklaus, Praise be Upon Him, for some
> inexplicable reason forced the Modula-2 programmer to use UPPERCASE
> keywords.
Which is as it should be. Upper case stands out; keywords (like
WHILE and IF) should stand out, given the impact they have on
the meaning of the code. Upper case is less readable; the
keywords form a small, closed set, which makes them immediately
identifiable despite this.
The fact that keywords and user symbols were not distinguishable
made early C significantly harder to read. (Today, of course,
syntax highlighting solves this problem, so it's no longer
a bother.)
> Or I think I remember that. Also it was nice with built-in
> coroutine support.
Above all, it had the best model for separate compilation that
I've ever seen. (If I understand correctly, David Vandevorde's
module proposal is based, at least for the semantics, on
Modula-2's modules.)
--
James
== 5 of 19 ==
Date: Tues, Nov 12 2013 3:51 am
From: James Kanze
On Tuesday, 12 November 2013 09:53:53 UTC, David Brown wrote:
> On 11/11/13 17:07, Victor Bazarov wrote:
> >> If there /is/ an overflow (i.e., the value cannot be represented), then
> > The term "overflow" as used by some other folks here is not the same as
> > "requires more storage than can be given". I believe the use of the
> > term 'overflow' relates to the situation that can be recognized by the
> > processor and appropriately flagged (or trapped). It is run-time
> > behavior (or situation), not hypothetical relationship between numbers
> > that exists at the compile time.
> I am not sure that we can make such subtle distinctions about the use of
> the word "overflow" - I think it is valid to use it in either sense.
I don't really see two different senses. Overflow is run-time
behavior (unless it occurs in a constant expression in
pre-C++11), since whether it occurs depends on the values
involved. But I think we would agree that if the data types had
enough bits, overflow wouldn't occur. (At the hardware level,
at least with 2's complement addition, overflow is defined as
the xor of the carry into the sign bit and the carry out of the
sign bit. Hardware doesn't consider the possibility that word
size can be increased.)
> As
> far as I can see, there is not "official" definition in the C++ standard
> (correct me if I'm wrong!), and no particular grounds for fine
> differentiation. To my understanding, a calculation "overflows" if it
> cannot be done while keeping the natural correspondence between the
> abstract idea (such as mathematical integers) and the concrete
> implementation (such as a an n-bit twos-complement number). So with
> 16-bit integers, 30000 + 20000 overflows - regardless of whether or not
> the processor flags it.
Almost all processors do flag it. (IIRC, the 8080 didn't. But
that was a long time ago.) The issue is whether the generated
code pays attention to the flag.
The Intel x86 processors have a special instruction
(INTO---interrupt on overflow) precisely to make it simple to
handle. A good compiler will, at least when the proper options
are given, insert this instruction immediately after each
operation.
[...]
> > So, given that your use of the term "overflow" appears different from
> > Alf's, I would recommend reviewing your understanding and your previous
> > statements in this thread. This might help you understand the
> > objections Alf had to what you had said/written.
> I have tried, but I don't see it. I don't think the issue of
> flagging/trapping is important in the discussion (though Alf has used
> "-ftrapv" with varying success in his tests).
Trapping is one of the possible "undefined behavior". The
preferable one, although on most hardware, it has significant
performance implementations if the compiler is to achieve it.
> I am very open to the
> idea that our disagreement was/is due to a misunderstanding on some
> particular term, but I think that we do understand each other, and we
> disagree. Alf thinks that signed integers should behave as module 2^n,
> that this is the "natural" behaviour (following the principle of least
> surprise),
Least surprise for who?
> and that compilers should follow that even though the
> standard says signed integer overflow is undefined behaviour. I think
> that there is no natural behaviour for signed integer overflow, that
> modulo behaviour is as surprising as any other behaviour, and that
> compilers can use the "undefined behaviour" tag to allow better
> optimisations.
The error isn't that signed overflow isn't module; the error is
that unsigned overflow is defined. There are cases where you
want an abstraction with modulo arithmetic (e.g. calculating
hash codes), but if you're using usual arithmetic, the
"abstraction" is the set of integers (an infinit set), and if
the abstraction is violated in any manner, you want an abrupt
and fatal failure. (Afterwards, of course, it's up to you to
validate the input, so that you can't end up in such a case.)
> It is unfortunate and regrettable that the argument seems to have got
> suddenly out of hand with Alf's later replies to my posts - I still do
> not see where his accusations come from.
> > According to the standard, the behavior is implementation-defined, that
> > means that whatever the behavior is, it shall be documented. The result
> > of such conversion *may* cause overflow (IOW allow such condition to be
> > registered and programmatically recognized and acted upon), but it does
> > not *need to*, nor does it *usually* happen.
The C standard makes this much clearer: the "results" are
implementation defined, and may include an implementation
defined signal being raised.
--
James
== 6 of 19 ==
Date: Tues, Nov 12 2013 4:37 am
From: "Alf P. Steinbach"
On 12.11.2013 12:51, James Kanze wrote:
> On Tuesday, 12 November 2013 09:53:53 UTC, David Brown wrote:
>> Alf thinks that signed integers should behave as module 2^n,
>> that this is the "natural" behaviour (following the principle of least
>> surprise),
>
> Least surprise for who?
Please don't pay attention to David Brown. Whenever he says something
about what others mean, you can be reasonably sure that it's at best
misrepresentation, and at worst a complete fantasy. In short, he's
heavily into misrepresentation and other forms of trolling.
Regarding the C++ expression at hand, -1/2u is well-defined, casting
that back to integer will in practice not incur overflow, not even on
one complement's machines are sign and magnitude, but the holy standard
does admit implementations with rather more perverse value ranges,
simply by not considering the possibility that they could exist...
One can trust David Brown to latch on to such, and also to not
understand whatever he's read about it (he thought -1/2u was UB).
Cheers,
- Alf (pretty annoyed at himself for being suckered into DB's world)
== 7 of 19 ==
Date: Tues, Nov 12 2013 5:15 am
From: "Alf P. Steinbach"
On 12.11.2013 11:45, James Kanze wrote:
> On Monday, 11 November 2013 19:24:57 UTC, Alf P. Steinbach wrote:
>> On 11.11.2013 19:54, James Kanze wrote:
>>> On Saturday, 9 November 2013 22:09:34 UTC, Alf P. Steinbach wrote:
>>>> On 09.11.2013 22:14, Ian Collins wrote:
>>>>> Alf P. Steinbach wrote:
>>>>>> This code is in support of some API functionality:
>
>>>>>> [code]
>>>>>> inline
>>>>>> auto can_inflate( gdi::Rect const& r, int const dx, int const dy )
>>>>>> -> bool
>
>>>>> Why do you insist on using this form rather than the sorter, more
>>>>> conventional form?
>
>>>> Uhm, the word "insist" incorrectly indicates some kind of opposition to
>>>> the adoption of `auto`. ;-)
>
>>>> Anyway, there are many good reasons, but for me the most important is a
>>>> consistent visual layout:
>
>>>> * function name at fixed place.
>>>> * return type visually separated.
>
>>> You mean like the way I've always written function definitions:
>
>>> bool
>>> can_inflate( ... )
>>> {
>>> }
>
>>> The function name is always at the start of the line. Has been
>>> since I learned C. (Back then, about all we had for searching
>>> was grep, and "grep ^can_inflate" would always get the
>>> definition, and nothing else.)
>
>> No, with C++11 that style can no longer (in practice) yield a consistent
>> layout, since in cases where the return type depends on the argument
>> types one avoids a lot of complication and verbosity by using `auto`.
>> For details of how bad it can be see Andrei's "min max revisited"
>> article in DDJ (I leave it to the reader to google it). For example,
>> even in C++11 you can NOT simply write
>
>> template< class T >
>> decltype( a*b ) mul( T a, T b )
>> { return a*b; }
>
> And you said something about avoiding complication... (Of
> course, in this case the return is just T, so any decltype is
> simply added verbosity. I suspect you meant for a and b to
> potentially have different types, however, in which case, it
> sort of makes sense. If you like implicit type conversions and
> unreadable code at the client level---but that too is a long
> tradition, dating back to C.)
>
> The question is: how often is something like this relevant?
> Perhaps if you're writting a very low level library, but
> certainly not in application code.
>
>> But you can write, and since you're pragmatic you will eventually write,
>
>> template< class T >
>> auto mul( T a, T b )
>> -> decltype( a*b )
>> { return a*b; }
>
> (Just to be clear: I think you really mean:
>
> template< typename T1, typename T2 >
> auto mul( T1 a, T2 b )
> -> decltype( a * b )
> {
> return a * b;
> }
That's also a possible example, with the possible advantage that it's
more obvious (has practical utility also for built-in types), and with
the drawback that it's more to type up and understand.
>
> . Otherwise, using decltype is just added verbosity.)
No, not at all. The result type does not need to be T.
>> So, your currently favorite style was good for C, to the degree that a
>> syntax that both the C creators and the C++ creator have described as a
>> "failed experiment", can be good. It was good in that sense also for
>> C++03. With C++11 it's IMHO just ungood, since it no longer covers all
>> cases and thus yields an inconsistent mix of declaration styles.
>
> It's good in the same sense that && and ||, rather than "and"
> and "or" are good. It's idiomatic for the language. It's what
> everyone reading the language expects.
Oh, standard C++ does have `and` and `or` with the usual boolean
meaning, and it's been that way since 1998.
> It's also good in the sense that seeing "auto" in front of
> a function triggers the reaction: here's some fancy, overly
> complicated template mess. Because the ubiquitous use today is
> not to use "auto", unless you need it for the decltype.
Times they are a'changing. Yes. :-)
> That doesn't mean that in an abstract, ideal world, something
> like:
>
> FUNCTION func( ... ) -> return_type
>
> wouldn't be better. But this isn't an abstract, ideal world;
> this is C++. And the keyword "auto" is the same as for
> a variable, so it doesn't add any additional information.
Oh it does.
> For the moment, all of this is new,
Well, two years old. ;-)
> so best practices haven't really been established,
Right.
> but generally, from what I can see so far:
> "auto" should be limited to variables containing "standardized"
> return values of member functions, where the type of the return
> value depends on the type of object the member function was
> called on. E.g.
>
> auto iter = container.begin();
>
> For just about anything else, it's simply additional
> obfuscation.
That's an opinion based on not using the feature, i.e. no experience,
and with no stated rationale other than a desire to keep on mainly doing
C++03 style code, which one is used to, and treating C++11 code as
exceptional.
In other words, it's a kind of brace-placement-convention argument.
But on the contrary, there are real savings by standardizing on a single
declaration form for value-returning functions -- as there always are
when one simplifies something and keep the functinality.
>> d>> Which means that the human eye finds it much easier to just scan through
>>>> the code to find a name or note the names, or inspect return types, with
>>>> no to read and analyze the text.
>
>>> You're style makes it harder to find the return type. (I never
>>> found this a problem in Modula-2, but C++ is not Modula-2.)
>
>> Hm, I can't remember much about Modula-2 declarations.
>
> See above.
>
>> I do remember that good old Niklaus, Praise be Upon Him, for some
>> inexplicable reason forced the Modula-2 programmer to use UPPERCASE
>> keywords.
>
> Which is as it should be. Upper case stands out; keywords (like
> WHILE and IF) should stand out, given the impact they have on
> the meaning of the code. Upper case is less readable; the
> keywords form a small, closed set, which makes them immediately
> identifiable despite this.
>
> The fact that keywords and user symbols were not distinguishable
> made early C significantly harder to read. (Today, of course,
> syntax highlighting solves this problem, so it's no longer
> a bother.)
>
>> Or I think I remember that. Also it was nice with built-in
>> coroutine support.
>
> Above all, it had the best model for separate compilation that
> I've ever seen. (If I understand correctly, David Vandevorde's
> module proposal is based, at least for the semantics, on
> Modula-2's modules.)
Amen.
Cheers, & hth.,
- Alf
== 8 of 19 ==
Date: Tues, Nov 12 2013 5:32 am
From: David Brown
On 12/11/13 12:51, James Kanze wrote:
> On Tuesday, 12 November 2013 09:53:53 UTC, David Brown wrote:
>> On 11/11/13 17:07, Victor Bazarov wrote:
>>>> If there /is/ an overflow (i.e., the value cannot be represented), then
>
>>> The term "overflow" as used by some other folks here is not the same as
>>> "requires more storage than can be given". I believe the use of the
>>> term 'overflow' relates to the situation that can be recognized by the
>>> processor and appropriately flagged (or trapped). It is run-time
>>> behavior (or situation), not hypothetical relationship between numbers
>>> that exists at the compile time.
>
>> I am not sure that we can make such subtle distinctions about the use of
>> the word "overflow" - I think it is valid to use it in either sense.
>
> I don't really see two different senses. Overflow is run-time
> behavior (unless it occurs in a constant expression in
> pre-C++11), since whether it occurs depends on the values
> involved. But I think we would agree that if the data types had
> enough bits, overflow wouldn't occur. (At the hardware level,
> at least with 2's complement addition, overflow is defined as
> the xor of the carry into the sign bit and the carry out of the
> sign bit. Hardware doesn't consider the possibility that word
> size can be increased.)
Agreed.
>
>> As
>> far as I can see, there is not "official" definition in the C++ standard
>> (correct me if I'm wrong!), and no particular grounds for fine
>> differentiation. To my understanding, a calculation "overflows" if it
>> cannot be done while keeping the natural correspondence between the
>> abstract idea (such as mathematical integers) and the concrete
>> implementation (such as a an n-bit twos-complement number). So with
>> 16-bit integers, 30000 + 20000 overflows - regardless of whether or not
>> the processor flags it.
>
> Almost all processors do flag it. (IIRC, the 8080 didn't. But
> that was a long time ago.) The issue is whether the generated
> code pays attention to the flag.
I work mostly with small processors, and I have used some that didn't
have an overflow flag. I used mostly assembly with those, though C
compilers existed for them (or "C-like language" compilers, as they did
not support all of C). One noticeable issue with these sorts of
processor is that signed comparison was expensive - without an overflow
flag, it took extra work.
But it has been a while since I used a CPU without an overflow flag
(though many don't have any kind of trap or interrupt on overflow).
>
> The Intel x86 processors have a special instruction
> (INTO---interrupt on overflow) precisely to make it simple to
> handle. A good compiler will, at least when the proper options
> are given, insert this instruction immediately after each
> operation.
>
> [...]
>>> So, given that your use of the term "overflow" appears different from
>>> Alf's, I would recommend reviewing your understanding and your previous
>>> statements in this thread. This might help you understand the
>>> objections Alf had to what you had said/written.
>
>> I have tried, but I don't see it. I don't think the issue of
>> flagging/trapping is important in the discussion (though Alf has used
>> "-ftrapv" with varying success in his tests).
>
> Trapping is one of the possible "undefined behavior". The
> preferable one, although on most hardware, it has significant
> performance implementations if the compiler is to achieve it.
Yes, if you have some sort of trapping enabled (either automatic in the
cpu in some way, or using INTO, or by compiler code that checks for
overflow and generates an exception) then you are typically going to get
bigger and slower code. Such traps limit the optimiser even if the
compiler doesn't have to generate extra code.
>
>> I am very open to the
>> idea that our disagreement was/is due to a misunderstanding on some
>> particular term, but I think that we do understand each other, and we
>> disagree. Alf thinks that signed integers should behave as module 2^n,
>> that this is the "natural" behaviour (following the principle of least
>> surprise),
>
> Least surprise for who?
For Alf, in this case (but that is part of my point - /I/ would find
modulo behaviour surprising, even though I know that it fits the
underlying hardware in most cpus).
>
>> and that compilers should follow that even though the
>> standard says signed integer overflow is undefined behaviour. I think
>> that there is no natural behaviour for signed integer overflow, that
>> modulo behaviour is as surprising as any other behaviour, and that
>> compilers can use the "undefined behaviour" tag to allow better
>> optimisations.
>
> The error isn't that signed overflow isn't module; the error is
> that unsigned overflow is defined. There are cases where you
> want an abstraction with modulo arithmetic (e.g. calculating
> hash codes), but if you're using usual arithmetic, the
> "abstraction" is the set of integers (an infinit set), and if
> the abstraction is violated in any manner, you want an abrupt
> and fatal failure. (Afterwards, of course, it's up to you to
> validate the input, so that you can't end up in such a case.)
There are many types of behaviour one could want for arithmetic (signed
and unsigned) when the result is outside the range. Modulo is one,
traps is another, saturating arithmetic is good sometimes, perhaps you
would like "errno" to be set, maybe you want the range to be increased
automatically (that would not work very well in C++ in general, but
works fine in Python and with big integer libraries), etc., - and of
course "undefined behaviour" and "implementation dependent behaviour"
are other options. I guess it's a matter of opinion and personal
preference which behaviour any given programmer would like for signed
and unsigned integers. Like it or not, in C and C++ we have "modulo"
for unsigned integers and "undefined behaviour" for signed integers -
programmers and compiler writers have to live with that, and take
advantage of that when they can.
Often when I am relying on modulo behaviour of unsigned "overflow" (it's
not really overflow, since by definition in C and C++ it is done as
modulo arithmetic), I will put things like "(a + b) & 0xffff" in my code
as a documentation that I expect modulo behaviour.
>
>> It is unfortunate and regrettable that the argument seems to have got
>> suddenly out of hand with Alf's later replies to my posts - I still do
>> not see where his accusations come from.
>
>>> According to the standard, the behavior is implementation-defined, that
>>> means that whatever the behavior is, it shall be documented. The result
>>> of such conversion *may* cause overflow (IOW allow such condition to be
>>> registered and programmatically recognized and acted upon), but it does
>>> not *need to*, nor does it *usually* happen.
>
> The C standard makes this much clearer: the "results" are
> implementation defined, and may include an implementation
> defined signal being raised.
>
== 9 of 19 ==
Date: Tues, Nov 12 2013 5:33 am
From: David Brown
On 12/11/13 13:37, Alf P. Steinbach wrote:
> On 12.11.2013 12:51, James Kanze wrote:
>> On Tuesday, 12 November 2013 09:53:53 UTC, David Brown wrote:
>>> Alf thinks that signed integers should behave as module 2^n,
>>> that this is the "natural" behaviour (following the principle of least
>>> surprise),
>>
>> Least surprise for who?
>
> Please don't pay attention to David Brown. Whenever he says something
> about what others mean, you can be reasonably sure that it's at best
> misrepresentation, and at worst a complete fantasy. In short, he's
> heavily into misrepresentation and other forms of trolling.
>
> Regarding the C++ expression at hand, -1/2u is well-defined, casting
> that back to integer will in practice not incur overflow, not even on
> one complement's machines are sign and magnitude, but the holy standard
> does admit implementations with rather more perverse value ranges,
> simply by not considering the possibility that they could exist...
>
> One can trust David Brown to latch on to such, and also to not
> understand whatever he's read about it (he thought -1/2u was UB).
>
>
> Cheers,
>
> - Alf (pretty annoyed at himself for being suckered into DB's world)
>
I don't know if you are reading this, Alf, but could you please just
drop this attitude? It helps no one, and I am sure I am not the only
one getting tired of it. /Nothing/ I have posted here has been
deliberate misrepresentation, lying, or intentional or active "trolling".
I make mistakes. It happens - it happens to everyone. The great thing
about Usenet is that errors get corrected by people who know more about
that particular topic. When I am shown clear evidence that I am wrong,
I accept that correction with thanks - as was the case with int(-1/2u).
Maybe I should be more careful about reading the standards before
posting and getting corrected - others have suggested that, and I'll
take that as constructive criticism for future posts.
== 10 of 19 ==
Date: Tues, Nov 12 2013 6:04 am
From: "Alf P. Steinbach"
On 12.11.2013 11:23, tomalak@gmail.com wrote:
> On Monday, November 11, 2013 11:37:46 AM UTC, Alf P. Steinbach wrote:
>> I've already replied to earlier postings of yours in this thread.
>>
>> You have demonstrated general incompetence, reasoning disability,
>> dishonesty and trolling.
>>
>> Plink.
>
> Alf,
>
> Please refrain from this unnecessary vitriol.
In Usenet forums it's a very good idea to plink the trolls (including
you) -- or to plonk the heavy-weight trolls, to show some last respect.
When most everybody did this, the troll activity was very low, since
they knew that only newcomers read their articles.
>This is a technical forum for the discussion of technical issues, and childish insults and finger-in-ear "la la la I can't hear you" screaming is off-topic. If you wish to "plink" someone then fine, do it, but there is no need to advertise the fact to the entire group, other than to "have the last word". Shame it's not even a real word.
>
> Let's all stick to the matter at hand.
>
> Thanks.
Please just stay over in the SO troll corral?
Trollfest in clc++, argh!
Plink.
- Alf
== 11 of 19 ==
Date: Tues, Nov 12 2013 7:01 am
From: Öö Tiib
On Tuesday, 12 November 2013 12:45:36 UTC+2, James Kanze wrote:
> On Monday, 11 November 2013 19:24:57 UTC, Alf P. Steinbach wrote:
> > On 11.11.2013 19:54, James Kanze wrote:
> > > On Saturday, 9 November 2013 22:09:34 UTC, Alf P. Steinbach wrote:
> > >> On 09.11.2013 22:14, Ian Collins wrote:
> > >>> Alf P. Steinbach wrote:
> > >>>> This code is in support of some API functionality:
>
> > >>>> [code]
> > >>>> inline
> > >>>> auto can_inflate( gdi::Rect const& r, int const dx, int const dy )
> > >>>> -> bool
>
> > >>> Why do you insist on using this form rather than the sorter, more
> > >>> conventional form?
>
> > >> Uhm, the word "insist" incorrectly indicates some kind of opposition to
> > >> the adoption of `auto`. ;-)
>
> > >> Anyway, there are many good reasons, but for me the most important is a
> > >> consistent visual layout:
>
> > >> * function name at fixed place.
> > >> * return type visually separated.
>
> > > You mean like the way I've always written function definitions:
>
> > > bool
> > > can_inflate( ... )
> > > {
> > > }
>
> > > The function name is always at the start of the line. Has been
> > > since I learned C. (Back then, about all we had for searching
> > > was grep, and "grep ^can_inflate" would always get the
> > > definition, and nothing else.)
>
> > No, with C++11 that style can no longer (in practice) yield a consistent
> > layout, since in cases where the return type depends on the argument
> > types one avoids a lot of complication and verbosity by using `auto`.
> > For details of how bad it can be see Andrei's "min max revisited"
> > article in DDJ (I leave it to the reader to google it). For example,
> > even in C++11 you can NOT simply write
>
> > template< class T >
> > decltype( a*b ) mul( T a, T b )
> > { return a*b; }
>
> And you said something about avoiding complication... (Of
> course, in this case the return is just T, so any decltype is
> simply added verbosity.
There are no such rule. Consider:
SquareMeters operator*(Meters a, Meters b);
or:
Duration operator-(TimeSpot end, TimeSpot start);
> I suspect you meant for a and b to
> potentially have different types, however, in which case, it
> sort of makes sense. If you like implicit type conversions and
> unreadable code at the client level---but that too is a long
> tradition, dating back to C.)
The operations with mixed operands are better example
indeed but something like:
template <typename T1, typename T2>
decltype( (*(T1*)0 * *(T2*)0 )
mul( T1 lhs, T2 rhs );
It looks rather ugly?
> The question is: how often is something like this relevant?
> Perhaps if you're writting a very low level library, but
> certainly not in application code.
Templates are either part of interface or low level libraries.
Various patterns of mixing and matching different types are
not so uncommon. Sometimes it is even nice to have with
one parameter because the type is too verbose:
// verbose: 'typename std::vector<T>::const_iterator'
template <typename T>
auto firstDuplicateInVector( std::vector<T> const& v )
-> decltype( v.begin() );
I also should scan some code bases for verbose or complex
return types and count. It is good idea to try to have uniform
style with as few of exceptions as possible so it is worth
trying out before deciding.
== 12 of 19 ==
Date: Tues, Nov 12 2013 10:47 am
From: James Kanze
On Tuesday, 12 November 2013 13:15:32 UTC, Alf P. Steinbach wrote:
> On 12.11.2013 11:45, James Kanze wrote:
> > On Monday, 11 November 2013 19:24:57 UTC, Alf P. Steinbach wrote:
> >> On 11.11.2013 19:54, James Kanze wrote:
> >> So, your currently favorite style was good for C, to the degree that a
> >> syntax that both the C creators and the C++ creator have described as a
> >> "failed experiment", can be good. It was good in that sense also for
> >> C++03. With C++11 it's IMHO just ungood, since it no longer covers all
> >> cases and thus yields an inconsistent mix of declaration styles.
> > It's good in the same sense that && and ||, rather than "and"
> > and "or" are good. It's idiomatic for the language. It's what
> > everyone reading the language expects.
> Oh, standard C++ does have `and` and `or` with the usual boolean
> meaning, and it's been that way since 1998.
I know. And no one uses them, and they still surprise
programmers. (They were, in fact, introduced as a work-around
for people whose keyboard didn't have a | or a &.)
> > It's also good in the sense that seeing "auto" in front of
> > a function triggers the reaction: here's some fancy, overly
> > complicated template mess. Because the ubiquitous use today is
> > not to use "auto", unless you need it for the decltype.
> Times they are a'changing. Yes. :-)
Very slowly. C++ isn't going to become Modula-2 anytime soon.
> > That doesn't mean that in an abstract, ideal world, something
> > like:
> > FUNCTION func( ... ) -> return_type
> > wouldn't be better. But this isn't an abstract, ideal world;
> > this is C++. And the keyword "auto" is the same as for
> > a variable, so it doesn't add any additional information.
> Oh it does.
What? What does it tell you, precisely.
> > For the moment, all of this is new,
> Well, two years old. ;-)
For whom? It's been less than a year that I've been able to use
a limited set of C++11, and most people I know in industry
cannot use it yet.
Whether it will change anything remains to be seen.
> > so best practices haven't really been established,
> Right.
> > but generally, from what I can see so far:
> > "auto" should be limited to variables containing "standardized"
> > return values of member functions, where the type of the return
> > value depends on the type of object the member function was
> > called on. E.g.
> > auto iter = container.begin();
> > For just about anything else, it's simply additional
> > obfuscation.
> That's an opinion based on not using the feature, i.e. no experience,
It's an opinion based on fact. In the case of variables, the
use of `auto` is pure obfuscation. It hides information
essential to understanding the code, like the types of
variables. (This is especially insideous, because some
programmers use unsigned types for numeric values.) In a very
few cases, the hidden information is obvious, and auto reduces
the verbosity enough to make it a win. But such cases are very
few.
> and with no stated rationale other than a desire to keep on mainly doing
> C++03 style code, which one is used to, and treating C++11 code as
> exceptional.
I clearly mentionned obfuscation.
> In other words, it's a kind of brace-placement-convention argument.
It's more along the lines of whether one should indent or not.
> But on the contrary, there are real savings by standardizing on a single
> declaration form for value-returning functions -- as there always are
> when one simplifies something and keep the functinality.
Yes, and such a declaration syntax exists and is already widely
used. I rather like the idea of keeping auto for the
exceptional cases: when I see auto, it tells me that someone is
more interested in playing around with new technology than in
writing code that works and that other people can understand.
--
James
== 13 of 19 ==
Date: Tues, Nov 12 2013 11:10 am
From: Ian Collins
Alf P. Steinbach wrote:
> On 12.11.2013 11:23, tomalak@gmail.com wrote:
>> On Monday, November 11, 2013 11:37:46 AM UTC, Alf P. Steinbach wrote:
>>> I've already replied to earlier postings of yours in this thread.
>>>
>>> You have demonstrated general incompetence, reasoning disability,
>>> dishonesty and trolling.
>>>
>>> Plink.
>>
>> Alf,
>>
>> Please refrain from this unnecessary vitriol.
>
> In Usenet forums it's a very good idea to plink the trolls (including
> you) -- or to plonk the heavy-weight trolls, to show some last respect.
Branding someone who disagrees with a troll is poor form. You are
possibly the only regular here (and on c.l.c) who considers David Brown
to be a troll. I can't see why.
--
Ian Collins
== 14 of 19 ==
Date: Tues, Nov 12 2013 11:13 am
From: "Alf P. Steinbach"
On 12.11.2013 19:47, James Kanze wrote:
> On Tuesday, 12 November 2013 13:15:32 UTC, Alf P. Steinbach wrote:
>> On 12.11.2013 11:45, James Kanze wrote:
>>>
>>> For the moment, all of this is new,
>>
>> Well, two years old. ;-)
>
> For whom? It's been less than a year that I've been able to use
> a limited set of C++11, and most people I know in industry
> cannot use it yet.
g++ has supported `auto` for more than two years, since version 4.4.0 in
april 2009.
visual c++ has supported `auto` for almost exactly one year now, since
the november 2011 CTP version (version number 17.00.51025, subtract 6 to
get the ms marketing department's notion of version).
i don't know about other compilers, sorry.
[snip]
> when I see auto, it tells me that someone is
> more interested in playing around with new technology than in
> writing code that works and that other people can understand.
ouch!
i think that's an unproductive attitude.
but then, here we're into feelings and emotional drivers, which i
believe are much tied to environmental factors such as the perceived
ideas of colleagues and the main kind of code produced (in particular,
library versus app), and i can only think of purely rational, logical,
Mr. Spock-like general arguments, already tried above :-(
anyway,
cheers & hth.,
- Alf
== 15 of 19 ==
Date: Tues, Nov 12 2013 11:27 am
From: "Alf P. Steinbach"
On 12.11.2013 20:10, Ian Collins wrote:
>
> Branding someone who disagrees with a troll is poor form. You are
> possibly the only regular here (and on c.l.c) who considers David Brown
> to be a troll.
Possibly, but not likely. :-)
Especially, what you say is unlikely given earlier comments asking why I
continued to engage in a clearly trolling thread, when I'd already
plinked some trolls here.
> I can't see why.
Because he doesn't just disagree, he mostly misrepresents and lies.
I define "lie" as when someone actively tries to convince others of that
which he (or she) knows is false, and I only say that in public when
it's proved. Or at least I hope I do. Anyway, he lies.
I think there should be room, here and in other groups, for all honest
people, also those (e.g. Aspberger's) who appear to many others to be
trolls. And I consider it worth fighting for persons who are wrongly
excluded or made subject of ad hominem campaigns, and so I've done that
(most recently elswhere, though). But I also think that the dishonest
ones should be plinked, and, unlike the opinon here of the only person I
ever killfiled on SO, that the reasons for such actions should be made
clear. If it's lying, then IMHO it needs to be said. In clear.
Cheers & hth.,
- Alf
== 16 of 19 ==
Date: Tues, Nov 12 2013 12:28 pm
From: Leigh Johnston
On 12/11/2013 19:13, Alf P. Steinbach wrote:
> On 12.11.2013 19:47, James Kanze wrote:
>> On Tuesday, 12 November 2013 13:15:32 UTC, Alf P. Steinbach wrote:
>>> On 12.11.2013 11:45, James Kanze wrote:
>>>>
>>>> For the moment, all of this is new,
>>>
>>> Well, two years old. ;-)
>>
>> For whom? It's been less than a year that I've been able to use
>> a limited set of C++11, and most people I know in industry
>> cannot use it yet.
>
> g++ has supported `auto` for more than two years, since version 4.4.0 in
> april 2009.
>
> visual c++ has supported `auto` for almost exactly one year now, since
> the november 2011 CTP version (version number 17.00.51025, subtract 6 to
> get the ms marketing department's notion of version).
>
> i don't know about other compilers, sorry.
>
>
> [snip]
>> when I see auto, it tells me that someone is
>> more interested in playing around with new technology than in
>> writing code that works and that other people can understand.
>
> ouch!
>
> i think that's an unproductive attitude.
>
> but then, here we're into feelings and emotional drivers, which i
> believe are much tied to environmental factors such as the perceived
> ideas of colleagues and the main kind of code produced (in particular,
> library versus app), and i can only think of purely rational, logical,
> Mr. Spock-like general arguments, already tried above :-(
If anyone else had said that you would have "plonked" them but you
realize if you also blacklist Mr Kanze you won't have anyone left to troll.
/Leigh
== 17 of 19 ==
Date: Tues, Nov 12 2013 1:03 pm
From: scott@slp53.sl.home (Scott Lurndal)
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> writes:
>On 12.11.2013 19:47, James Kanze wrote:
>> On Tuesday, 12 November 2013 13:15:32 UTC, Alf P. Steinbach wrote:
>>> On 12.11.2013 11:45, James Kanze wrote:
>>>>
>>>> For the moment, all of this is new,
>>>
>>> Well, two years old. ;-)
>>
>> For whom? It's been less than a year that I've been able to use
>> a limited set of C++11, and most people I know in industry
>> cannot use it yet.
>
>g++ has supported `auto` for more than two years, since version 4.4.0 in
>april 2009.
Why should that matter? My current C++ project needs to compile on various
versions of GCC from 4.1.2 to 4.6.4. We certainly cannot use C++11 features
and don't expect to be able to for several years to come, if then.
C++ is perfectly usable without all the C++11 cruft which, when used for
silly reasons (your -> auto return value declarations) just makes the code
harder to read and maintain. I do like the built-in threads in C++11, but
pthreads work just fine here.
And no, we cannot upgrade to newer compilers without serious and very costly
disruption. Probably won't start using C++11 until a new project is started from
scratch that has no external binary dependencies (which seems unlikely at the
moment). I suspect this is the norm for most real-world projects with more than
a single programmer on the team and more than a single C++ project within a product.
== 18 of 19 ==
Date: Tues, Nov 12 2013 1:21 pm
From: David Brown
On 12/11/13 20:27, Alf P. Steinbach wrote:
> On 12.11.2013 20:10, Ian Collins wrote:
>>
>> Branding someone who disagrees with a troll is poor form. You are
>> possibly the only regular here (and on c.l.c) who considers David Brown
>> to be a troll.
>
> Possibly, but not likely. :-)
>
If there are any others who think I am a troll, or have been lying or
deliberately misrepresenting facts, then please let me know. (And if
anyone knows specifically what Alf is talking about, and can point to
where I have lied - or written something that could be interpreted as a
lie - then let me know of that too.)
Like most people, I make occasional factual errors. I accept
corrections, possibly after a discussion about /why/ I am in error. And
if it was a silly mistake that I could easily have checked, then I feel
silly about it - but no one else should feel insulted or angry as a
result, nor should they mistake an error for a lie.
Like most people, I disagree with a number of opinions held by others in
this group - that is neither an error nor a lie.
> Especially, what you say is unlikely given earlier comments asking why I
> continued to engage in a clearly trolling thread, when I'd already
> plinked some trolls here.
>
>
>> I can't see why.
>
> Because he doesn't just disagree, he mostly misrepresents and lies.
>
> I define "lie" as when someone actively tries to convince others of that
> which he (or she) knows is false, and I only say that in public when
> it's proved. Or at least I hope I do. Anyway, he lies.
>
> I think there should be room, here and in other groups, for all honest
> people, also those (e.g. Aspberger's) who appear to many others to be
> trolls. And I consider it worth fighting for persons who are wrongly
> excluded or made subject of ad hominem campaigns, and so I've done that
> (most recently elswhere, though). But I also think that the dishonest
> ones should be plinked, and, unlike the opinon here of the only person I
> ever killfiled on SO, that the reasons for such actions should be made
> clear. If it's lying, then IMHO it needs to be said. In clear.
>
I agree that /if/ someone is lying, it should be called out (though not
judged and condemned until the case is clear). And I agree that it
should be "in clear" - and yet I am at a loss to see what you are
referring to as my lies and deliberate misrepresentation. I can only
assume that something I wrote particularly irritated you in some way -
perhaps I was unreasonably sarcastic in a comment. In the interest of
peace in this newsgroup, and a return to technical discussions, I will
be happy to apologise if I have insulted you in some way.
So let me know /exactly/ what the problem is, and we can put this behind us.
>
> Cheers & hth.,
>
> - Alf
>
== 19 of 19 ==
Date: Tues, Nov 12 2013 1:50 pm
From: Ian Collins
David Brown wrote:
Something Alf should see...
> On 12/11/13 20:27, Alf P. Steinbach wrote:
>> On 12.11.2013 20:10, Ian Collins wrote:
>>>
>>> Branding someone who disagrees with a troll is poor form. You are
>>> possibly the only regular here (and on c.l.c) who considers David Brown
>>> to be a troll.
>>
>> Possibly, but not likely. :-)
>>
>
> If there are any others who think I am a troll, or have been lying or
> deliberately misrepresenting facts, then please let me know. (And if
> anyone knows specifically what Alf is talking about, and can point to
> where I have lied - or written something that could be interpreted as a
> lie - then let me know of that too.)
>
> Like most people, I make occasional factual errors. I accept
> corrections, possibly after a discussion about /why/ I am in error. And
> if it was a silly mistake that I could easily have checked, then I feel
> silly about it - but no one else should feel insulted or angry as a
> result, nor should they mistake an error for a lie.
>
> Like most people, I disagree with a number of opinions held by others in
> this group - that is neither an error nor a lie.
>
>> Especially, what you say is unlikely given earlier comments asking why I
>> continued to engage in a clearly trolling thread, when I'd already
>> plinked some trolls here.
>>
>>
>>> I can't see why.
>>
>> Because he doesn't just disagree, he mostly misrepresents and lies.
>>
>> I define "lie" as when someone actively tries to convince others of that
>> which he (or she) knows is false, and I only say that in public when
>> it's proved. Or at least I hope I do. Anyway, he lies.
>>
>> I think there should be room, here and in other groups, for all honest
>> people, also those (e.g. Aspberger's) who appear to many others to be
>> trolls. And I consider it worth fighting for persons who are wrongly
>> excluded or made subject of ad hominem campaigns, and so I've done that
>> (most recently elswhere, though). But I also think that the dishonest
>> ones should be plinked, and, unlike the opinon here of the only person I
>> ever killfiled on SO, that the reasons for such actions should be made
>> clear. If it's lying, then IMHO it needs to be said. In clear.
>>
>
> I agree that /if/ someone is lying, it should be called out (though not
> judged and condemned until the case is clear). And I agree that it
> should be "in clear" - and yet I am at a loss to see what you are
> referring to as my lies and deliberate misrepresentation. I can only
> assume that something I wrote particularly irritated you in some way -
> perhaps I was unreasonably sarcastic in a comment. In the interest of
> peace in this newsgroup, and a return to technical discussions, I will
> be happy to apologise if I have insulted you in some way.
>
> So let me know /exactly/ what the problem is, and we can put this behind us.
I case Alf really has plonked you, he'll see this!
--
Ian Collins
==============================================================================
TOPIC: WHAT DOES ISLAM SAY ABOUT TERRORISM ?????????????????
http://groups.google.com/group/comp.lang.c++/t/6bd3b1012d72d85b?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Nov 12 2013 2:40 am
From: tomalak@gmail.com
On Thursday, November 7, 2013 7:09:50 PM UTC, BV BV wrote:
> WHAT DOES ISLAM SAY ABOUT TERRORISM?
Although I understood the above code, I couldn't get it to compile.
Could you please tell me which compiler flags you used?
Thanks.
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment