« first day (88 days earlier)      last day (4853 days later) » 

2:00 PM
it's equally going to be almost impossible to write correct Objective-C with just new, delete, and raw pointers
 
So don't use raw pointers
2
 
smart types and retain/release implement the same thing
just one of them is extendable by the user
and one isn't
 
yes. but smart types have to be explicitly written in.
 
which is that smart types can accomplish any user-defined action in any way
so what?
so does retain and release
 
you can't just return a pointer to something, you need to return a smart pointer to the thing
and
on at least one axis
 
2:01 PM
so it makes the ownership explicit
that's not a bad thing
 
0
A: hiding inherited functions.

Alf P. SteinbachI've confirmed the behavior with TDM MinGW g++ 4.4.1. It's a g++ bug, please report it. Cheers & hth.,

 
the desirability of a computer language is measures on how clearly it allows one to express the ideas of the program
in c++ one spends too much time dealing with the implementation of the algorithm
 
yes
 
I hope I'm not wrong there. It hit me that there just can be some obscure wording somewhere?
 
and explicit smart types are explicit
in C++, I don't deal with any shared_ptr implementation
I just write shared_ptr
 
2:03 PM
also, on both XCode and MSVC9/10
the STL is an abomination to try and debug.
 
yes, templates can produce pretty bad error messages
 
They seem to have forgotten the fine art of stepping over language implementation...
 
but I don't think that ObjC provides anything even close enough
and the genericity provided by templates is well worth a couple bad errors
 
so, error messages, and even just trying to step into what looks like a simpel dereference
turns into a mad dive through stl implementation
 
@ChrisBecke (1) you shouldn't have to debug down into std library code. (2) see the FAQ for link to template error message prettifier.
 
2:05 PM
templates could have been avoided by the simple expedient of adding "types" as first class variables to c++
 
yeah
via templates
they were
 
sbi
@JohnDibling Not all programming professors are clueless. I have been teaching C++, you know. :)
 
@alf - i don't want to debug DOWN to STL. But when using a stl iterator, I care about the call back into my object
 
@ChrisBecke nope, doesn't work with C++ object model. u need to study C++.
 
the only way to get to my object is to trace through stl
 
2:06 PM
I didn't know that@sbi
 
sigh
I know that
 
sbi
@AlfPSteinbach I'm not sure what three double-dotted i are supposed to mean, but I'll take your "Yeah, yeah" as agreement.
 
the point was to build a time machine, go back to stroustrup in 84 or whenever, and suggest it to him
so it would be.
 
sbi
@JohnDibling I wasn't a professor, though, but only an external lecturer. I did this beside my main job as a developer.
 
types can't be added as variables to C++
you need full-blown reflection
which is a very, very nontrivial thing to implement
 
2:09 PM
@ChrisBecke You should really read "The Design And Evolution of C++". The problem has been known since forever.
 
there is no real reason that Stroustrup couldnt have decided to make "class" somewhat more than a simple shim of "struct".
 
@ChrisBecke Yes there is. He wanted as little space and time overhead as possible, so the abstractions are affordable. Nobody would use std::array<T, n> if it wasn't exactly as efficient as good old T[n].
 
@sbi ΐ ΐ ΐ (they're actually triple-dotted, but difficult to see here :-) )
 
of course there was a reason for the design of class, at the time
but it has landed us in a place where the only direction forward for c++ is deep into ugly
 
what do you mean?
how is class supposed to be different to struct, exactly?
 
sbi
2:11 PM
But in principle, I share your sentiment. My students were always very surprised when they tried to turn in their first homework, and I didn't even look at their program's output, but wanted to see their source code. ("I'm sure you can turn in a program with output as expected. I want to see how you did it.) Apparently none of their professors had ever wanted to see their code.
 
@ChrisBecke If you don't like the path C++ has taken, feel free to choose another language.
 
because I think that
T[n];
is a far more clear statement
std::array<T,n>
than
 
sbi
For their first assignment, the first 60% didn't manage to get their program approved by me on first try. (The other 40% had been watching and learned.) For later assignments this usually became better.
@AlfPSteinbach Double or triple, I still don't know what it means.
 
If I wanted someone to read, and understand the intent of my code
 
@ChrisBecke I disagree strongly, std::array says very clearly that we are dealing with an array.
 
2:12 PM
T[n] wins
 
I have to agree with @FredOverflow
std::array is extremely explicit about what it is
 
std::array<T,n>
 
@sbi Hm, I'm not going to scoure Unicode for double-crossed t's.
 
If i want my code to be "correct"
then std::array<T,n>
 
sbi
@AlfPSteinbach Ah, now I get it. Sorry for being so dense.
 
2:14 PM
C++0x is right around the corner! codeguru.com/cpp/misc/article.php/c18357__1/…
 
the problem with C++'s primitive arrays is that they had to be backwards compatible with C's
which had many, many incredible problems
 
@DeadMG The good news is: nobody is forcing you to use C arrays in C++, but if you need C arrays, they are waiting for you.
 
what. the automatic promotion of arrays, to pointers was a good thing not a bad thing
 
no, Chris, it's a terrible thing
 
if the same idea had been extended to classes, then references could have been tossed, as
 
2:16 PM
because now, you lost whether or not I have a pointer to a character, or an array of characters
 
@ChrisBecke re all your "interesting" assertions, are you trying to stimulate debate (to put it that way)?
 
and, if I have an array, what size it was
 
Class a;
Class* b=a;
b.method();
a.method();
would all have been valid
 
@FredOverflow: Exactly, which is why I like C++ :P
Chris: So what? That's terrible code
 
im definately tryig to stimulate debate
i dont know
why I am as I realize its all a bit futile
 
2:17 PM
@ChrisBecke That must be one of the stupidest coercions ever. It is responsible for the common false assumption that arrays and pointers are basically the same thing.
 
we don't actually have a time machine
 
worst is 2D arrays
and people get so confused when a char[][] can't be a char**
 
so even if we did arrive at a consensus that c++ is deeply flawed, we can't do anything about it.
 
C++ is deeply flawed, but not in terms of it's core concepts
rather in terms of the usability
 
@DeadMG Exactly.
 
2:18 PM
things like #includes are the biggest problem in C++
the language doesn't need garbage collection, it doesn't need (major) syntax changes
 
@DeadMG right, because C++ is for making larger things than in C.
 
@DeadMG Oh yes, lack of modules is number 1 on my "Why C++ sucks" list.
 
what it needs is to axe old things from C, like array->pointer conversion, and fix many usability problem
 
the design of new, delete, and class are where I pin the problems. the rest of the syntactical sugar thats now necessary to write correct code follow on from those core issues
 
Chris, how is class supposed to be different to how it is now?
 
2:19 PM
@chris there's a difference btw stimulating debate and trying to reach the end of a conversation with everyone agreeing with you
 
lol
thats also true
 
well
 
but
 
pretty much all you've done is raise a point, have everyone in the room disagree with you, and try another point
 
After modules, the thing I would most like to see would be more full support for covariance. Not necessarily arguments (we've done without that successfully) but covariant method implementations. I think it could be fused with support for generic const/non-const implementations.
 
2:20 PM
you've never defended your own opinions in a real fashion
 
there is an idea that, in a debate, one is trying to convince at least some people of the validitiy of ones ideas
 
I think that const should be CUT
CUT CUT CUT
there, I said it
 
const is one of the things I like
 
That's the lawyers definition
 
@DeadMG What do you suggest as an alternative?
 
2:21 PM
@DeadMG I think const should ideally have been the default.
 
I don't suggest an alternative
 
I would like a stronger const
 
I think that it is a fundamentally useless idea
except for the language's terrible handling of rvalues
in C++03, anyway
 
@DeadMG Really? I think it's great we can distinguish between modifying and non-modifying member functions.
 
I think that I spend so much time faffing around making my code const-correct, and it pretty much never happens that I actually declare something as const
 
2:22 PM
a lot of languages have the idea of thread safe data via thread safe arrays & lists of immutable items.
 
thread safety and constness are very different- you can't implement thread safety using const
it's a start, but nowhere near enough
 
exactly
 
@ChrisBecke Immutable objects are practically useless in a language with value semantics and without garbage collection.
 
which is why I wish there was a stronger const
 
const would be OK if it was more
automated
 
2:23 PM
a transformation on an object to produce an immutable copy - ie.e one with no non const references
 
I will admit that even though I am a proponent of const correctness, const does seem to be contrivedly self perpetuating
 
the cost to programmer time should be far less than it is now to justify the rare use cases
 
the act of casting the immutable qualifier from an object would implicitly invoke a copy constructor
 
I've actually been thinking
that templates and concepts can solve the problem of const
 
const objects are quite rare, but const views of objects I find quite useful.
 
2:24 PM
in some (many?) places
 
Hey, how about one of you asks on SO "What's wrong with const?"? Could lead to an interesting discussion.
 
sbi
re garbage collection:
Oct 29 '10 at 20:44, by sbi
Yeah, GC takes all the worries about memory management, but leaves you out in the cold with all the other resources. That sucks.
 
@sbi: We know, you do not like garbage collection ;)
 
done
 
GC or not. is again. a project level decision
it should be an optional feature
 
2:26 PM
But for immutable value objects, garbage collection is great.
 
0
Q: What's wrong with const?

DeadMGI would like to know of the issues with const in C++ and C++0x.

tried to word the question so that it wouldn't get closed for being subjective
 
A very concise question :)
 
sbi
@ChrisBecke It actually is. If you want C++ with GC, use a GC implementation for C++.
 
I feel that it's fairly self-explanatory
 
oh yes? where does one find such a beast?
 
sbi
2:27 PM
@DeadMG I don't know what to do with it except voting to close.
 
C++/CLI, for a start
 
oh crikey. I opened myself up to that. theres a boost::gc isnt there?
oh crikey. thats not c++.
 
@sbi: Preferably, you would post known shortfalls of const
but hey, someone else suggested I open it
 
i dont know what to do except vote close.
 
you know, I have a theory about accept rate
 
2:29 PM
its either argumentative / subjective or "i just don't know what the #$*% youre asking"
 
sbi
@DeadMG "It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form."
 
hey
it seems pretty simple to me
although I did edit it
we had an identical question about ADL just, like, yesterday
 
@sbi - I think a juicy invective is just as appropriate there, but yes, thats the one I was thinking of.
 
sbi
@DeadMG The difference is that ADL does have issues.
 
Maybe it belongs on programmers
 
2:31 PM
Something wrong with posting "None." as an answer?
const has plenty of problems, like the inane time requirements for const-correct code and the rarity of actual const objects
 
sbi
@DeadMG Ok, I played the rep whore going for this.
 
oh, I thought you were going to accuse me of being a rep whore :P
 
anyhow, im amused that while its generally agreed that everyone disagrees with my position against exceptions, why you're anti const?
 
I feel that const objects are extremely rare, but the time taken to make classes const correct is much too long
 
sbi
@DeadMG If you think you know of a problem, why don't you ask about that? I don't know those you posted, and I'd be interested in learning about them.
 
2:33 PM
the developer time spent using const is much less than he spends maintaining const
 
sbi
@DeadMG What, thinking whether a method should alter the object it's invoked on and typing const (plus, maybe, a space) is too long? Hell, how fast to you cook up your methods' implementations, that this is relevant?
3
 
I think its very valuable to be able to declare that a method does not change the state of an object, passed in by reference
 
I can conceive of all my method's implementations at the same time
but I have to write const over and over again
 
sbi
I spend much more time thinking about my methods' implementations than on whether theses implementations should change the object.
 
especially in methods where the const implementation is identical to the non-const implementation
 
2:35 PM
if all the code is your own, thats fine
 
like accessors and index operators
 
if you are calling into some other library
method(someobjectofyours&);
is very different to
method(someobjectofyours const&);
 
not really
if it's not a pre-provided library type
then there's no reflection
so that method can only call methods that it arranged for my object to have in advance
besides, I've been thinking of concepts as an alternative to const
the control is much more fine-grained and, more importantly, quite optional
 
sbi
@DeadMG Accessors often are a sign of quasi classes.
3
 
but not always
maybe my class is a container type
 
user69820
2:38 PM
I can't wait 'til I get to the point where I understand what you lot are going on about
 
sbi
No, not always.
 
plus
 
user69820
sigh
 
I actually found a time a week or two ago when I had to use get/set
in my Text object
 
sbi
@oraclecertifiedprofessional C++., no? See, now you know what we're discussing about. :)
 
2:39 PM
in the Direct3D version, then it was just get/set member variable
but in the Direct2D version, it has some relatively complex caching behaviour
 
sbi
@DeadMG I have written these, too. But I found myself doing this less and less the longer I wrote programs.
 
well, if you have a better idea as to how I can implement an abstraction over both Direct3D text objects and Direct2D text objects
I'm all ears
 
@DeadMG Even if you never use a const object, const is still useful! For example, it can tell you "this function will not modify its input". How great is that?
 
not particularly
 
user69820
@sbi I knew I should have read the chat room name. Save a bit of effort, I thought. Now it's come back to bite me.
 
2:42 PM
either I wrote the function or I read the documentation
 
@Fred - exactly
 
and if you want to start enforcing design contracts, then const is just a very, very minor step in that direction
 
sbi
@oraclecertifiedprofessional You're very welcome. :)
 
I love the ability to knwo
what is input and what is output, to a method
 
@DeadMG I think it's great to be able to write foo( "blah" ), when foo has a ref to const formal argument.
 
2:44 PM
@ChrisBecke Exactly. We're on the same page here.
 
that's only necessary because C++'s string literals and references to rvalues are totally broken
C++0x fixes rvalue references, thankfully
but string literals are a great example of const being a band-aid over actually fixing the problem
 
@DeadMG Could you explain that in your "const question"? Or would that be off-topic?
 
@DeadMG But that's in a way fallacious argument, because if there was no const, presumably there would be no rule forbidding temp object to bind to non-const ref.
 
@Alf: Uh, what do you think rvalue references are?
rvalues binding to const references only was an incredible mistake
 
@DeadMG Not part of C++98.
 
2:45 PM
as it forbids move semantics, which are really quite important
@Alf: I'm fairly sure that this discussion focuses on my opinions, not what C++98 says
or rather
the discussion focuses on const and I am putting forth my opinions
 
I don't want to give the impression that I am not interested in what you say, because, well, else I wouldn't be here :P
but as soon as you accept that rvalue references are a better solution than const references to rvalues, then you have to start wondering, where else is const hindering rather than helping?
 
@DeadMG I would really like to read in detail your thoughts about const, rvalue, reference and how it could be done better. Maybe you should have asked a question with all three of these concepts thrown into the pot.
 
even I would instantly close such a question as subjective
that's not a question, it's a discussion
and I love discussions, but SO is not a forum
truth is, I would like to see some features where I just can't see how they can be in a language
instead of in an IDE
like template constraint auto-generation
 
0
Q: prolonging the lifetime of temporaries

FredOverflowWhat is the design rationale behind allowing this const Foo& a = function_returning_Foo_by_value(); but not this Foo& a = function_returning_Foo_by_value(); ? What could possible go wrong in the second line (which would not already go wrong in the first line)?

 
2:55 PM
Hah, I removed silly comment.
 
lol
 
i still think that custom cv qualifiers would be nice
along with a strong or weak rule.
 
@Fred: the canonical example is void incr( unsigned& v ) { ++v }, called with int x = 41; incr( x ); But I think could be handled by not creating temporary in this case, even though temporary could bind to ref to non-const. Perhaps one should check what Visual C++ does, since it generally allows binding temp to ref to non-const.
 
define_cv insecure;
read_from_user(insecure string& s);
string s2 = s; // error
 
I just checked, it doesn't allow the conversion.
Unsure about the more general case, though.
 
3:00 PM
string validate(insecure string& i);
string s2 = validate(s); // works
 
@Alf: That program's bad behaviour isn't solved by making rvalues bind only to const references, the bad behaviour is solved by making the rvalue not bind to a normal lvalue reference
The two are not the same
 
perhaps concepts supercede this. but I think there is a real need to extend the set of cv qualifiers to allow other sorts of correctness checks.
 
@Chris Becke: You're right in one way- C++'s support for contract enforcement is terrible
 
and automatic coersions.
 
const is just a drop in the ocean
 
3:05 PM
custom qualifiers could help. but probably don't go as far as other approaches.
 
I think that concepts are the important thing here
and proper modules
and deprecating array->pointer conversions and solving the needless initializer/constructor syntax circlejerk
and properties/other automatic conversions
 
deprecate -> and :: while youre at it
 
If a question is closed and reopened and then closed again, can we reopen it again? Is there any hard limit on this?
 
@FredOverflow: I've never seen a question closed, reopened, closed, and reopened
but I expect that if it occurs more than a couple times, a mod will come in and fix it one way or the other
 
wtf is the use of: namespace::objectptr->object.method, when each of the ::, -> and . is essentially doing the same thing. looking the name up in the next namespace.
 
3:10 PM
@DeadMG Maybe your const question will be the first one in the history of SO? :)
 
ok, . and -> are required to disambiguate between an object and its pointer for the purpose of operator overloading.
but still, teh nuber of times a Object& changes to a Object* in a parameter list. followed by lots of search replace on obj. to obj->
 
hey, it's open again
Chris, that just means you don't know the semantics of your function
pick one and stick with it
@FredOverflow: It seems open enough to me.
 
@DeadMG It's open for the second time, and I was wondering what would happen if it was closed for the second time ;)
 
sbi
@FredOverflow I doubt so. I've seen many such wars fought. I think I've seen at least four cycles of this.
 
well
I have to admit that the initial question could have been worded better
but I don't think that the edit I applied a couple minutes later is worthy of a close vote
 
sbi
3:17 PM
The thing is, when you have voted to close a question, and that question gets re-opened, you can't vote to close again. (And I don't think you can vote to re-open either.)
 
so everyone who's gonna vote has already voted
and we'd have to wait for new people to come online before the question can be closed or re-opened again
 
@DeadMG: btw what is a "shortfall", a mixture between "shortcoming" and "pitfall"? :)
Also, in C++, you don't fall short, you fall long long ;)
 
lol
a shortfall is a financial term meaning not meeting expectations
 
@DeadMG ah, didn't know that.
 
like investments can have a shortfall
oh
am I also the only one who thinks that this whole int, short, long, long long rigmarole is ridiculous?
 
3:21 PM
@DeadMG What do you mean?
 
well
I think that the vast, vast majority of C++ is written against int being 32bit, for example
how many shorts aren't 16bit?
more importantly
if the language won't guarantee the size of an int, it's pretty useless if you might run into overflow
so you have to resort to the uint8_t stuff anyway
if you aren't gonna overflow, you just use int because it's quick to type
 
Yeah, I also like well-defined primitives better.
 
so what's the point of short or long long or long?
 
btw you have ever tried long long long on gcc? ;-)
> error: long long long is too long for GCC
 
lol
 
3:25 PM
class average_joe
{
    short temper;
    long member;
};
 
lol
 
3:37 PM
wow
was just reading up on SCARY iterators
man, I had never even considered that
 
@DeadMG what is that?
 
they basically point out that having a separate iterator for std::set<int, std::less<int>> and std::set<int, std::greater<int>> is stupid.
which it really, really is
and you have to repeat a shitload of algorithm and other template instantiation to accomodate the waste
I love the name, too
SCARY iteration
 
@DeadMG Funny, I stumbled upon that myself a few weeks ago.
 
I just
I'm amazed that it never occurred to me
I just kept on typing container::iterator without thinking about it
well
I guess that strictly speaking, it's a library implementation issue, not library interface
mostly
 
4:04 PM
It was proposed to mandate SCARY iterator implementations in C++0x, but I think that was deferred IIRC.
 
yes
I got the link from Bjarne Stroustrup's interview with somebody
 
45. "A C program is like a fast dance on a newly waxed dance floor by people carrying razors." - Waldi Ravens
 
Are there any freely-available implementations of containers that support SCARY iteration?
 
GNU and STLPort both have SCARY iterators
the article I linked mentions which STLs are SCARY and which aren't
 
@Dead: Would you please stop saying SCARY, it scares me ;)
 
4:17 PM
but I love it
the idea that iteration could be SCARY is just hilarious
aaah, it's an iterator! RUN!
 
@DeadMG That's nice. I never thought about attempting to assign set<int, std:less>::iterator to set<int, std::greater>.
 
no, me neither
probably because the support for custom template types in the STL sucks as it is without named parameters in functions or templates
the amount of cack it takes to define the type of and instantiate a std::unordered_map with a custom allocator is unbelievable
 
Oh, I didn't know the using directive allowed to include method names. Is this C++03?
 
yep
 
Damn it, my printer wouldn't print the scary paper at first. Guess why? Turns out I forgot to open the printer :)
 
4:19 PM
lol
what, so it could escape from SCARY iteration?
but I think that it has a valid point
 
Hmmm. I just tried assigning an set<int, std::greater<int> >::iterator object to an set<int, std::less<int> >::iterator object. It doesn't seem to work: codepad.org/Z9kZmwn9
 
which is that there's no reason that std::set<int, std::less<int>> should have a different iterator to std::set<int, std::greater<int>>
@Daniel: No guarantee that uses the latest GNU STL
especially since that code is compiled as debug
the paper mentions one lib which does use all three parameters in it's iterator in debugging mode
 
@DeadMG Yes, that must be it. I tried it with g++ 4.5.0 and it compiled without error.
 
Check the version printing __GLIBCXX__.
 
surprised it's notin boost
 
4:29 PM
@jweyrich I get: __GLIBCXX__ = 20100414
 
Codepad prints 20070214, looks like it's gcc 4.2.1 or older.
 
4:43 PM
4.1 and 4.2 are currently <= 2007-11-01, 4.3 <= 2008-03-23, 4.4 <= 2009-04-19, and 4.5 <= 2010-11-08. Unless you replace the implementation without changing/updating the compiler. Maybe there's a better way to check this.. dunno.
 

« first day (88 days earlier)      last day (4853 days later) »