« first day (187 days earlier)      last day (4779 days later) » 

5:08 PM
hello folk
 
Hi Johannes. How are you this evening?
 
i'm fine thanks. how are you?
 
Pretty good too, thanks. I have a report due today, but somehow SO seems to take priority...
 
cpx
@JohannesSchaublitb hello
 
SetThreadPriority(stackOverflowThreadHandle, THREAD_PRIORITY_TIME_CRITICAL);
 
cpx
5:16 PM
@JamesMcNellis lol
 
@JamesMcNellis Except it's really supposed to be: SetThreadPriority(stackOverflowThreadHandle, THREAD_PRIORITY_IDLE);
 
@JerryCoffin It's too late to change it now. ;-)
 
@JamesMcNellis Probably...
 
Als
Hey All just need a quick advice...what should one read first "C++ Templates: The Complete Guide" or "C++ Standard Library, A Tutorial and Reference"
I want to learn more about Templates and Standard Template library but seems like a egg or a chicken scenario right now..
@JerryCoffin, @JamesMcNellis, @JohannesSchaublitb: Anyone?
 
5:27 PM
I think I'd recommend that latter first.
 
note, though, that the design of the STL is hardly a "modern" C++ design where its use of templates is concerned
 
Als
Yes In the Complete guide, I saw a note about knowing STL in what should know before reading
 
cpx
second, assuming if you know the basics about templates.
 
It gives an idea of how to use the existing infrastructure. After that, The Complete Guide gives you more guidance about how to do more on your own.
 
@cpx the basics being what they're for - that's pretty much all you need to know until you start meta-programming
 
5:29 PM
@Als if you want to learn more about templates and the standard library. hmm dunno, but I would take the first first. the first doesn't require any knowledge about the standard library. it's a language-only book (but still contains some programming techniques like CRTP and expression templates, but everything independent of the standard lib)
 
Als
@JerryCoffin, @RonaldLandheerCieslak, @cpx: Thanks guys..latter it is then...need to run off..have a nice weekend
 
@Als You too.
 
why not buy both and then read both
 
@Als someone, maybe you, has asked that before
 
How do you guys read a book? Do you have a dedicated time? Do you take notes? Do you read from begin till the end, or just pick the interesting parts?
 
5:36 PM
@StackedCrooked mostly I try to read from begin to end, though I rarely manage, so I pick interesting bits if I don't manage and keep for reference guide
 
i read my first c++ book ("c++ in 21 days") around 5 pages a day before going to sleep. i remember how I sweated when reading because reading books in bed I find awkward. reading books anywhere is kinda awkward IMO
haven't found a solution to this problem yet
 
@JohannesSchaublitb Are you comfortable reading text on a monitor?
 
@StackedCrooked Depends on the book, but I almost never just read a book about programming directly through from beginning to end. I almost never do the exercises exactly as-is either -- I nearly always think "but wouldn't it be more interesting if..." and do something vaguely similar, but almost never quite the same. Doing programming in conjunction with the reading is important, just not necessarily exactly what they assign.
 
Quick check for my own sanity... std::vector doesn't overload operator& does it?
 
@CharlesBailey I don't think so, no.
 
5:41 PM
@JerryCoffin I agree that experimenting beyond the exercises really helps to understand the stuff.
 
@StackedCrooked yeah
the compiler dragon book just arrived. I surfed a bit in it and I think it's amazing. I should have bought it long before
 
Dear oh, dear. A lot of rubbish is being written. stackoverflow.com/questions/5747455/…
 
Johannes, btw, your first C++ book was "C++ in 21 days"? :)
 
@JohannesSchaublitb So, ..would you recommend it?
 
5:45 PM
no haha
 
The last book I read was "Programming Clojure". I found that I can better stay focused if I take notes while reading. The extra benefit was that I ended up with a nice little reference (docs.google.com/View?id=df3sq6bv_115c5bgjwp3&pli=1).
 
Clojure eyes and I'll kiss you...
 
However, I still have "The C++ Programming Language" sitting on my desk. And I don't really know how to approach that one.
@CharlesBailey IEUW!!
 
@StackedCrooked Does that stand for something or is it purely onomatopoeic?
 
@CharlesBailey "Eeeew" would have been correct. However, in my panic I resorted to dutch phonetics.
 
5:52 PM
dammit I accidentally voted for reopening a question
ill ask a mod to remove my vote
 
Copy/paste shortcuts don't seem to work on this chat on Mac Firefox.
Well, paste works, copy doesn't.
 
std::array is strangely uncontainer-like.
 
@CharlesBailey How so?
 
@StackedCrooked It doesn't construct empty, swap is linear and might throw and doesn't transfer iterators between the swapped containers.
Unlike all the other standard containers.
 
@CharlesBailey The standard containers implement swap in constant time?
 
5:58 PM
@StackedCrooked All, apart from std::array. (Obviously I'm talking C++0x, but it was true for C++03, too.)
 
swap(vector & a, vector & b) ; // is constant time?
 
@StackedCrooked Technically, it's a specialization that calls a.swap(b) and std::vector::swap is required to have constant complexity.
 
@StackedCrooked Yes -- and, as Charles said, it can't normally throw either (even if any operation on the elements would throw). As such, it basically can't do anything with the elements themselves.
 
@CharlesBailey It is a specialization that just swaps the internal pointers then?
 
@StackedCrooked Yes -- vector has a swap member function, and there's a required specialization that makes std::swap invoke the member function. (§23.2.4.4/1).
 
6:01 PM
@StackedCrooked :624737 Technically, it's a specialization that calls a.swap(b) and std::vector::swap is required to have constant complexity.
 
cpx
 
Hmmm, edited instead of posting anew. Messed up the threading there. Assume a std::forward.
 
@cpx Yes, and?
 
cpx
I'm interested to see the new edition.
 
@cpx One hour a day, but the number of days are unbounded...
 
6:08 PM
O(inf)
 
OMG, the first flow control construct they teach is goto. The go on to say it is generally bad, but really, why even bother?
2
 
@DeadMG lol
@CharlesBailey OMG I am disgusted
that's like teaching singleton as the first pattern
oh, that does happen quite often :P
 
Page 168 for anyone using Amazon's look inside.
 
as the first anti-pattern, you mean
 
@DeadMG why bother teaching it? it sucks, that's all
 
6:10 PM
agreed
I think that it's a pattern that applies to so few situations really that it's not worth teaching
 
cpx
@CharlesBailey Hm, idk why would it say 1 hour a day if days are unknown.
Maybe they let the readers count lol
 
@cpx it's a seller trick to get you to buy it, cause it seems easy that way
 
@DeadMG At some point people need to learn it -- even if they never write a goto themselves, they do exist in the world, and reading that code can be a valuable skill. I don't thin it belongs in an introduction like this though.
 
oh, I was talking about Singleton
 
cpx
@TonyTheTiger Possibly. its an old trick though.
 
6:13 PM
@DeadMG Oh -- same situation applies though..
 
agreed
things like that and arrays-as-pointers-to-first-element should really be left to the end
 
@DeadMG yep, cause at the beginning they could only create confusion
 
under "C++ you should never have to know or use but we teach just because some poor guy had to use it thirty years ago"
 
@DeadMG lol
 
@CharlesBailey I think the goto got it's bad reputation from how it was used in languages like Basic. I don't think it can be abused in C++ as much. So I don't see much harm in using it. Even though I never found the need to use it.
 
6:19 PM
2
Q: How can I refactor this C++ to remove the labels/gotos?

SSpokeHello my problem is not really a problem but I want to make this code look a bit more elegant then it currently it has spaghetti code. here is a little example what I got. int func(...) { if ( ... ) { v6 = ESI_1C; EBP = 1; v5 = 0; v21 = 0; v19 = 0; v25 = ESI_1C; ...

 
honestly, it's more like, there's no need to use it and there are lots of dodgy language rules around it
 
@DeadMG I think that in C it's sometimes the only way to avoid a few cpu cycles.
 
well there are two major problems with that
 
Xeo
gotta admit, I like the arrays-as-pointers-to-first-element rule
 
firstly, a more understandable/reasonable program is well worth a few CPU cycles
and secondly, that's C, and this is C++, so I really don't care
thirdly, I really don't see any situations in which it's any more efficient
 
6:24 PM
@DeadMG you really not a C fan are you...
 
there's nothing wrong with C, it's just designed for 40 years ago
 
Xeo
@DeadMG will you argue the same way for c++ in 20 years?
 
@DeadMG so what parts of C are most out-dated, if you can call it that?
 
and it really does annoy me when people act as if what's true for C is true for C++
yes, I likely will
well, let's start with almost the entire Standard library
 
@DeadMG that annoyance I can understand
tbh I didn't know the difference before I started, so it seems to be a common confusion
 
6:26 PM
then you have no good meta-programming support (preprocessor definitely does not count), no proper strong typing, arrays as pointers
 
@DeadMG I'm having a problem with the allergic reaction towards goto. I believe there may be situations where it is the best option. However, all the stigma makes it very hard to make a rational decision on whether or not to use it.
 
but can you replace C in all circumstances with C++, as in where you would use C, could you use C++ in all cases?
 
in all cases in which somebody made an implementation, certainly
 
@StackedCrooked a very few extremely rare cases might require a goto, but I think only extremely few, I'd classify it like the singleton
hmmm
 
@StackedCrooked: I'd happily judge each case on it's own merits; but I've seen goto used hundreds of times and never once was it justified
I'll certainly admit that not every C++ feature is suited to every development area, but in the case where a similar C feature exists (e.g. malloc vs new), then I absolutely would replace it
of course, there's actual costs for doing this when replacing legacy code is involved
 
Xeo
6:29 PM
@StackedCrooked there are situations where it's the most cleanest option
 
just out of curiousity, when you replace a goto with a function call, you have more overhead on the function call, prob negligable in most cases though?
 
Xeo
@TonyTheTiger you either get a function call or an inlined function
 
no, not even probably
firstly, you can have it inlined
 
cause goto can be translated to assembler most literally, no? I seem to recall seeing a similar thing in asm with labels and all that
@DeadMG oh yea, I forgot about inlining
 
Xeo
@TonyTheTiger __asm jmp label;
 
6:31 PM
secondly, a constant jump to a function is probably going to be the same as a constant jump
 
Btw, is it possible to goto a previous line?
 
@Tony: There's also if statements in asm
 
I've only seen usage of forward goto (in C++).
 
you can have jne, jnz, etc
 
@StackedCrooked afaik you can anywhere
yea I know about those :)
#
 
Xeo
6:32 PM
you can even jump across functions if my mind doesn't fail on me
 
@TonyTheTiger You can only goto a location inside the current function scope I thought.
 
cpx
I never used goto in C++, except in batch programming.
 
Xeo
lemme test it
 
@Xeo I'm already on it.. :)
 
Xeo
i always have my playgroung project open for these cases :)
>error C2094: label 'print' was undefined
so, no
only in function scope
 
cpx
6:35 PM
It would be crazy if you could skip on any line of code anyway.
 
@Xeo Makes sense. What if two functions were to define a label with the same name?
 
Xeo
@StackedCrooked funny thing, just paste http://stackoverflow.com into an empty line in your c/c++ source and compile. :)
 
honestly, with RAII and stuff, then goto just doesn't make any sense
 
@Xeo Sneaky bastard! :)
@DeadMG RAII doesn't allow you to escape nested loops.
 
Xeo
@StackedCrooked After finding that for the first time, I never again looked at web-addresses the way before
 
6:45 PM
This makes me feel nostalgic (of the C64 BASIC days):
#include <iostream>

int main()
{
std::string name;
std::cout << "Please enter your first name: ";
std::cin >> name;

sayhello:
std::cout << "Hello " << name << "!\n";
goto sayhello;

return 0;
}
 
cpx
@StackedCrooked Does it end up crashing in endless loop?
 
@StackedCrooked lol, I never had my programs print "please" (when I was writing programs at that level, in pascal in grade 8 or so :)).
 
@Xeo I will now look at them with my head slightly tilted.
@cpx It doesn't crash. It just goes on.
@Eugene Indeed, it was more like: "what is your name"
 
My programs had sufficient attitude to be running on evil robot overlords.
 
Xeo
@StackedCrooked "Your name or your life, decide."
 
6:49 PM
@Xeo :)
C64 Basic was more succinct though:
10 PRINT "Hello $NAME"
20 GOTO 10
I'm not even sure if this is the right syntax.
 
I think it needs a reading operation too
 
Xeo
One last closing vote in here, first come first served! stackoverflow.com/questions/5748261/…
 
10 Input "Enter your name: ", N$
20 print "Nice to meet you ", N$
30 goto 10
 
Xeo
huch
damn tabbing
 
@Xeo I won!
 
6:56 PM
I need some 'shaving for dummies' guide, because I can't seem to do it. It ends up in blood and tears. Every time. My face is now made of pain. Dammit.
 
@PiotrLegnica Isn't that how it's supposed to be? Have I been doing it wrong all this time?
 
And I didn't even manage to get rid of everything. Not going back there. Ow.
 
If you writing method "remove(item*)" that removes an item from a container (or anything else that has add/remove methods) then how do you deal with the situation that the item was not found? Do you ignore it or throw an exception?
 
Xeo
i think the STL deals with it by throwing on vectors, or by return false on other things.. don't know exactly
 
7:01 PM
@Xeo Oh crap.
 
Xeo
Don't need drugs if you know the right websites.
 
@Xeo set and map don't throw here.
 
@StackedCrooked I'd say ignore it. You want it gone, so what's the difference if it weren't there in the first place?
Postcondition is still held.
 
@PiotrLegnica Sometimes it could be useful to return a bool.
It can be easily ignored, and you can use it if you want.
 
cpx
@Xeo I was waiting for the monster to show up. I need to re-watch now lol
 
7:03 PM
@PiotrLegnica I tend to agree. In the past I would have thought of this as sloppy code. However, "remove" methods are likely to be called from inside destructors. So exceptions would be risky here.
 
Yeah, bool is good.
 
@PiotrLegnica But could be ambiguous. False may indicate that removal failed.
 
you've got the contract wrong
the purpose of "remove" is not to remove an object from the container
it's to ensure that after the operation, the container does not have that object
 
Xeo
@cpx Sometimes the internet tells the truth :D
 
@DeadMG Says who?
 
Xeo
7:06 PM
re·move/riˈmoÍžov/
Verb: Take away (something unwanted or unnecessary) from the position it occupies.
 
says me, I'm pretty sure that it's my name next to the chat
 
Xeo
@DeadMG that would be erase
 
Is the C++ standard available online (for free)?
 
0x FDIS is in pinned messages.
 
What about 03?
 
7:10 PM
> — no erase(), pop_back() or pop_front() function throws an exception.
 
Xeo
available online, not for free
 
@Xeo You can find drafts C++0x, but that's a bit risky.
 
cpx
@StackedCrooked yes, but I never bothered to look up for it yet.
 
Xeo
@StackedCrooked I meant for 03
and why would drafts be risky?
 
Drafts are available for free, but you have to pay for final standards.
 
7:12 PM
@DeadMG Difference being that remove does nothing if the object cannot be found in the container.
 
@JerryCoffin I never understood why that was.
 
@Xeo Because it's apt to change.
 
@Xaade: As it should do
 
@MartinhoFernandes Because selling standards is how the ISO makes most of its money.
 
Insinuating that remove MUST remove from the container suggests that remove should throw an exception or report an error if the item doesn't exist.
 
7:15 PM
@StackedCrooked You could always use enum Bool { True, False, FileNotFound };.
 
lol
 
@PiotrLegnica Sure.
 
It might be useful to find out the item didn't exist in the container. However, this shouldn't disrupt flow, or cause the program to cease functioning.

Unless the user intends to, at which point they can check if the item exists before removing.
 
@JerryCoffin That's why I prefer ECMA :)
 
@PiotrLegnica Although, "FileNotFound" is somewhat too specific for an enum called "Bool"
 
Xeo
7:16 PM
@PiotrLegnica Boost.Tribool :)
 
enum Result { succeed, fail, <other> }
 
@MartinhoFernandes I'm not sure it's really preferable. ECMA is funded by vendors, which can (does?) give the vendors what some would consider excessive control over the results. At least in theory, ISO should be a bit more independent.
2
 
@StackedCrooked It's an old TDWTF thing. ;)
 
Or do like microsoft.

return bool.
if (!method(arg,...))
{ err = GetLastError(); }
 
7:18 PM
no, don't do that
 
@Xaade I would prefer not to. ;)
 
It's funny when you forget to SetLastError though. "Error: No error."
 
@StackedCrooked
Stack : How to solve problem X
ChatA : Solution A
ChatB : Solution B
Stack : Don't like those.
Chat? : Uh.... ok.
 
@Xaade I assumed your suggestion was a joke.
 
@StackedCrooked Partial joke, partial facepalm.
I find it funny when people ask something but don't like any of the answers.
Not that it's their fault, because the answers may not be helpful at all.
For the people that offer suggestions, it's dismal.

It's like holding a net below a cat in a tree.... waiting for it to jump down. Then switching to a tarp, and a pillow, and etc.

I feel like that when offering suggestions to my wife.
 
7:24 PM
@PiotrLegnica This reminds me: today I had to write new code and mark it as deprecated. New code, that is nowhere used yet, had to be marked deprecated for backwards compatibility. Aarg..
 
One day you realize, that the cat goes up into the tree to get away from you.
 
@Xaade I'm confused. Did I offend you, or are you just joking around?
 
Xeo
@StackedCrooked backwards compatibility sucks
 
@Xeo Yeah, and colleagues that force you to write code according to their broken design sucks even more.
 
BC is good for users.
 
7:30 PM
I guess I'll be forthright now.

People should just assume that I'm always joking.
I often get in raging arguments... for fun.

I find irony hilarious, which is why some of my jokes don't translate well to people that find irony disrupting, even painful.
At work, frustration is fun. If I'm not beating my head against a wall and yelling, I'm bored to death.
(Frustration at problem solving, not frustration at dealing with people who make stupid decisions)
 
Fuck, I just heated a salad that was supposed to be eaten cold.
 
Blame a vegetarian and order a pizza.
 
@Xaade Pizza it is. (The salad containd tuna so I can't really blame the veggie.)
 
Don't worry about that..... Tuna isn't a cute animal....
Veggies don't defend tuna
 
:)
Brb. Getting pizza.
 
cpx
7:36 PM
Mmmm
 
I'm wondering, when a vegetarian's pet cat eats a cockroach, does the vegetarian cry?
 
lool
 
Seriously.... True vegans don't drink beer.... it exploits the bacteria.
 
@Xaade ...and never use antibiotics, because they kill bacteria too.
 
There are people who try to force their carnivorous pets to be vegetarian. I call them morons.
 
7:40 PM
back
 
cpx
@TonyTheTiger welcome back.
 
@PiotrLegnica Wouldn't that exploit the animal.
To assume their cause.
 
I can't imagine a thought pattern that leads to the 'hey, that's a good idea' conclusion.
 
Look, if I can get a lion to do it, then it must be right, because animals have a better sense of morality than people.
 
7:56 PM
@MartinhoFernandes I like how the documentation says that "specifies a tri-state Boolean value," but then it goes on to define all five (not three) possible states (only two of which are supported?).
 
Xeo
Wikipedia. Start: /dev/random - Current Station: en.wikipedia.org/wiki/Names_for_the_number_0_in_English - Goal: ???
Via: Windows NT
 

« first day (187 days earlier)      last day (4779 days later) »