« first day (572 days earlier)      last day (4394 days later) » 

3:00 PM
hey guys
 
hello.
 
I need your opinion on something
 
@TonyTheLion It doesn't even mean "extends" in that context, it means "subtype of" (extends or impements).
 
Language and surrounding technologies are two different things.
 
@TonyTheLion It's encapsulation violation and a waste of a keyword.
 
3:00 PM
@Fanael Sorry, I'm starting to suspect I either dreamt of it, or made a terrible confusion. I know there's an answer on SO about that kind of thing, but I can't seem to find it.
 
Why should I have written ZeroMQ in C, not C++ http://bit.ly/Kpxf89
 
Hi guys care to take a look at this snippet?
http://ideone.com/nNDh3
 
I believe that the article is a fundamentally wrong analysis of the problem
on the other hand, the author obviously knows his stuff, and in particular, he knows the project’s architecture intimately well
so I was wondering if there’s an error in my reasoning in my comment (up in a second)
 
@TonyTheLion Erm, yeah. I'm not a slacker!
 
He also failed to count to more than 1.
 
3:02 PM
why does the compiler hate
void Foo<typename B::TYPE>::setValue()
 
user784668
@CatPlusPlus lol, rite
 
@Olumide Because there's no B.
> The problem with that is that you have no idea of who and where is going to handle the exception
That's a problem, why?
 
@FredOverflow What about MyClass.<SomeTypeParameter>myMethod() for calling generic methods? That is the awesomest!
 
@KonradRudolph He's a numpty.
his fundamental problem is that he doesn't understand exceptions
 
@RMartinhoFernandes right, just because last time I spoke to you about that, you were still looking for work, glad you found something :)
 
3:03 PM
> Consider the case when the exception is not handled in the function that raises it.
Like, every case?
If you handle the exception in place, don't raise an exception. Duh.
 
@CatPlusPlus I thought it could stand for any class that has an enum called TYPE
 
@KonradRudolph He didn't mention exception safety, so I'm somewhat skeptical of the claims.
 
@Olumide Where does B come from, is it a template parameter? Can we see more surrounding code?
 
@Olumide You can't just invent an identifier out of the air and expect it to automagically work.
There's no B defined in this snippet anywhere.
> As you fix individual bugs you'll find out that you are replicating almost the same error handling code in many places.
 
user784668
@CatPlusPlus I thought it works with foo and bar.
 
3:04 PM
Which means you fail at handling errors, and shouldn't be doing it at that level.
@Fanael But they're magical.
> If you don't give up on the "no undefined behaviour" principle, you'll have to introduce new exception types all the time to distinguish between different failure modes.
What.
 
Undserstood. I was trying to specialize getValue() for types that have an enum called TYPE. Is this line of thinking correct?
 
@LucDanton of all of them or of a specific claim?
 
If I ever design a language, I'll make foo and bar keywords that stand for unnamed identifiers.
3
That sounds as ridiculous as it probably is.
 
@Olumide Specialising member functions is ugly.
 
@KonradRudolph Claims that the C-style error handling is more elegant.
 
3:06 PM
But you need to partially specialise in your case
 
Or conversely, that using exceptions means awkward error-handling code.
 
@CatPlusPlus Probably. But is it allowed?
 
So it'd be template <typename B> void that_thing::set_value<typename B::something> { ... }
Or something to that effect.
No, wait, your member function isn't a template.
You can't specialise it at all.
 
@LucDanton Hmm, yes
 
You have to specialise the type.
 
3:08 PM
ok, my comment is up now
 
@CatPlusPlus Drat! So I have to specialize the entire class?
 
What are you trying to solve, anyway?
> At this point you may be screaming: That's what exception specifications are for!
Oh gawd, he really doesn't know much about exceptions.
 
Ye, also another red flag.
 
If anyone has a moment, does anyone know how to do what this question asks? stackoverflow.com/questions/10527441/construct-a-long-long
 
3:09 PM
That's the vibe I get throughout the whole thing: he doesn't understand the things.
 
impressive
 
@CatPlusPlus Its part of a large application. I've factored out the current problem that I'm having.
 
> When you create an instance of the class, constructor is called (which cannot fail) and then you explicitly call init function (which can fail).
 
So, I think he derived some pretty reasonable conclusions from some wrong premises.
 
Fail, fail, fail, fail, fail, fail.
You fail.
> If that's the case a special new object state comes into being.
No it doesn't, you just fail.
 
3:10 PM
I just received 20 Careers invites. If you're interested, plink me.
 
Lol at turning every class into a state machine.
 
@CatPlusPlus Maybe he meant that it shouldn't fail.
 
@RMartinhoFernandes What is this 'plink'?
 
user784668
@SamDeHaan this?
 
@SamDeHaan This is plink.
 
3:11 PM
@SamDeHaan It's the sound it makes when you @lert me.
 
@Neil It should fail if it can fail.
 
Ah. Magic.
 
@CatPlusPlus No, that's pseudo-code to illustrate. He's right about that, too. E.g. std::fstream::close is allowed to fail, and will put *this into a failed state (although in the case of std::fstream that's not a new state).
 
Otherwise you're dealing with zmobie objects.
fstream also sucks.
 
@RMartinhoFernandes I'm not surprised. With that many SO points.
 
3:13 PM
@RMartinhoFernandes Well, if you're throwing them out to anyone lucky enough to be in Lounge at the moment, I'll take one.
 
@TonyTheLion Bustin Jieber lol
 
Dammit, I got dressed an hour ago to go to the shop.
And I didn't.
Damn you all.
 
@SamDeHaan Send me your e-mail to M8R-gt1qwe@mailinator.com
 
@CatPlusPlus Still holds for any type that has a failible operation that must run in the destructor. If you expose that operation (which is sensible, since you want to be able to catch errors), and it does fail, then there's a window where the object is in a failed state.
 
@FredOverflow lol
 
3:14 PM
I don't agree that's a problem, but the analysis is sound.
 
@LucDanton Let it fail silently. You can’t react meaningfully to a failure in file.close() anyway, except not to use the object anymore
 
room topic changed to Lounge<C++>: Home of the time vampires. [c++] [c++11] [c++-faq]
 
Java throws a checked exception in file.close
Now that's a fail.
 
I take that back partly, since reporting the error to the user might still make sense, in case the failure to close was caused by a failure to flush the write buffer to disk, for instance
 
3:15 PM
@TonyTheLion But yeah, that's an impressive talk for a 12 year old.
 
@FredOverflow yep
 
@KonradRudolph How about no? Files are just an example anyway (and a good example: what you can do is check errno).
 
@CatPlusPlus It's a major nuisance that has finally been sorta fixed in Java 7 with AutoCloseable.
 
when I was 12 years old, I only got interested in C++ programming
 
the Windows documentation does not mention any instances in which closing a file could fail.
 
3:16 PM
I'm a latecomer, didn't even have a computer until I was 13
 
@RMartinhoFernandes Spam sent.
 
@TonyTheLion I can't remember exactly what I did when I was 12. Probably vocabulary trainers or something.
 
cleanup should never fail; if it does, something bigger has gone wrong
 
3:17 PM
@DeadMG You mean like at Three Mile Island? :)
 
@FredOverflow What does an island have to do with exception handling?
 
It's an exceptional island.
 
@SamDeHaan You should have it now.
 
@DeadMG I meant the cleanup at the nuclear plant.
 
@DeadMG Nuclear power plant incident.
 
3:18 PM
@DeadMG Lets just say, you would risk more than memory leaks.
 
@LucDanton errno in C++?
 
@Neil lol
 
@CatPlusPlus I suppose the addendum to that post shows that what matters it not so much having a clean-up function that can fail, but having a clean-up function that can give useful information since a destructor can't.
 
@LucDanton Arguably, you could log or something similar from a destructor.
 
how many Viagra spam emails can one receive?
it's rediculous
 
3:19 PM
@RMartinhoFernandes Thanks
 
@TonyTheLion ALL THE EMAILS
 
user784668
lol
 
user784668
0
Q: Objects without classes - data model in 'clean C'

Mikołaj SiedlarekI've worked with C++ on some medium-sized project, but I have never did any serious programming in C. Having read this article I've started wondering how I could use C++11 without classes and exceptions. I once heard the term clean C. Clean C supposed to be a C++ code which doesn't use C++ featu...

 
@DeadMG If *this could always know what to do, then 'error-handling' wouldn't be a thing.
 
3:21 PM
Oh, me and @MooingDuck (and possibly other passers-by) had this T::close() vs T::~T() discussion before here.
 
@RMartinhoFernandes the outcome was?
 
Good question – but note that the article you link to is currently getting trounced in the C++ chat. — Konrad Rudolph 39 secs ago
 
user784668
@RMartinhoFernandes It's obvious you both were wrong, for the real solution is T.~this().
 
@TonyTheLion I convinced him that throwing from dtors was not a good idea and close() was a necessary evil if you want to handle errors from cleanup.
 
@RMartinhoFernandes I never said it was a good idea to throw from dtors, that's a disaster waiting to happen. I just questioned DeadMG's assertion that no cleanup could ever error.
(Even if it can, do not throw from dtors)
 
3:26 PM
@KonradRudolph #include <cerrno>.
 
@MooingDuck Or that. Sorry if I misrepresented your position :(
 
oh I see
 
@RMartinhoFernandes it was subtle, and a ways back. Easy mistake
 
@LucDanton Yes but then you’re effectively capitulating
 
@KonradRudolph No, I'm using std::fstream to its full-spec (possibly relying on QoI too though). What good are failbit and badbit alone for error-reporting?
 
3:28 PM
> Unfortunately, attempting to use any good (whether haskell-ish or not) style in Java tends to result in verbose code, which is not good style, and therefore it is impossible.
So true.
 
@TonyTheLion How exactly does Viagra spam taste? ;)
 
@LucDanton Hmm. True
I never do error reporting for file IO failure :p
fortunately I’ve gotten away with it so far
 
@LucDanton "while(cin >> myobject) {" (That's about it)
 
@FredOverflow Filling.
 
@MooingDuck When I said 'what good are [they] alone' I was suggesting that they are in fact complimentary to errno. Not questioning what purpose they serve.
 
3:31 PM
@RMartinhoFernandes source?
 
> What kind of self-respecting programmer doesn't have the ASCII table memorized?</snark>
lol
 
@LucDanton errno doesn't tell you the type of error. The state is inherently an IO error. I don't like errno, because you don't know the type of error. IMO.
 
@MooingDuck errno tells you the type of the error as an integer constant.
 
@MooingDuck Complimentary. As in, you're using it in tandem with the badbit and failbit of std::fstream. How can it not be an IO error? Should I use more emphasis?
 
3:34 PM
if(errno == EBAD) { // something bad happened
} else if(errno == EAPOC) { // Bruce Willis didn't blow the asteroid up
}
 
@LucDanton Think you mean complementary, sir.
 
@Neil Thank you.
 
Did anyone invent a programming language called Chuck Norris yet?
 
@FredOverflow Chuck Norris invented it, but it was too badass to comprehend.
 
3:36 PM
Mr. errno: Oh, Mrs. failbit you're stunning!
Mrs. failbit: Thank you my dear.
2
 
Chuck Norris doesn't need a programming language, computers just do what he wants anyways.
2
@RMartinhoFernandes lol
 
@RMartinhoFernandes Alternatively, you get a free errno every time you check the stream state.
 
Using the Chuck Norris programming language, if the compiler has errors, it gets a roundhouse kick in the face and makes it run correctly anyway.
 
@TonyTheLion Aren't you confusing with Jon Skeet?
 
3:38 PM
We should create a hybrid, the ultimate Master, Chuck Skeet :P
or Jon Norris
 
I launch NetBeans IDE and the first thing I get is "JVM creation failed"
Java sucks already
 
Xeo
@RMartinhoFernandes meaning you can have as many foos and bars in a single scope as you want? :P
 
@TonyTheLion Do you have a JVM installed installed on your computer?
 
@Xeo Hmm. Maybe. There's a reason I'm not a language designer...
 
3:41 PM
@FredOverflow I thought I did
 
bin in the path?
 
hmm I installed the JDK and Netbeans
does that include the JVM?
 
Did you install the JDK with or without the JRE?
I don't know about Netbeans, but Eclipse does not need the JDK since it comes with its own compiler. It needs the JRE though.
1
Q: list is not sorting at all

codrgiii am updating a list and then trying to sort the list putting the highest sVar1 at the front of the list, but it is not doing it, i'm using 6.0 VS while(Iter != m_SomeList.end()); { if((*Iter)->sVar1 == 1) { (*Iter)->sVar1++; } Iter++; } m_SomeList.sort(Descendin...

Visual Studio 6 lol
 
For the love of whatever God you believe in, GET OFF OF VS 6.0!! — John Dibling 3 mins ago
lol
@FredOverflow Sounds like a "call your headhunter!" scenario.
 
@RMartinhoFernandes Have you been watching the GoingNative videos lately? :)
 
user784668
3:48 PM
@FredOverflow But Visual Studio 6 is a very good compiler! …when compared to compilers from the '80s.
 
@FredOverflow I watched that one live.
 
@Fanael I loved developing with Visual Studio 6 back in the days, but that was a time where I didn't even know there was such a thing as a std::vector.
 
user784668
I wonder if it supported std::vector.
 
It did support the basic stuff, but advanced templates made VS6 puke.
Also, there was that for-loop-scoping issue.
 
user784668
@FredOverflow That's still quite good for a pre-standard compiler.
 
3:57 PM
13
Q: When are two algorithms said to be "similar"?

RachitI do not work in theory, but my work requires reading (and understanding) theory papers every once in a while. Once I understand a (set of) results, I discuss these results with people I work with, most of whom do not work in theory as well. During one of such discussions, the following question ...

@RMartinhoFernandes: according to that question, whether or not my sort is a quicksort or not is "subjective" :(
 
user784668
@MooingDuck your sort?
 
@Fanael Sure it did. maps, valarrays, two flavours of iostreams :) the whole lot. Just not partial template spec., template members, correct twophase lookup, low limits on template recursion, etc. No hash tables, hash maps: basically nothing towards TR1
I used to code - MFC with template-driven DDX mechanisms :)
 
@Fanael I made a in-place quicksort ideone.com/4iCSo, but RMartinho challenged if it's actually a quicksort or not anymore.
 
@sehe AFAIK, correct two-phase lookup is still not there.
 
user784668
@sehe Two flavors of iostreams? What the heck was that?
 
4:01 PM
relevant: en.wikipedia.org/wiki/In-place_algorithm "In computer science, an in-place algorithm (or in Latin in situ) is an algorithm which transforms input using a data structure with a small, constant amount of extra storage space. "
 
@Fanael <iostream> and <iostream.h> You don't wanna know
@RMartinhoFernandes I was too lazy to mention that
 
user784668
@sehe Ah, an almost standard one and some old stuff resembling iostreams?
 
If I have a global and I want to access it from a signal handler, must that global be volatile?
I thought I read that somewhere in the Standard some time ago, but I cannot find it back.
 
user784668
> signal handler
 
@Fanael - iostream.h is pre-standard, the functions weren't wrapped in the std namespace
 
user784668
4:08 PM
@birryree I know.
 
I guess it was not the '?' of curiosity, but an '?' of "oh wow, WHY"
 
My latest attempt at specilizing class Foo for types that have an enum TYPE,
http://ideone.com/Am3iH
 
@classdaknok_t volatile sig_atomic_t. And you can't do just everything with that, even.
 
@LucDanton even if I just read from it? If it must be a sig_atomic_t, I'm pretty much screwed since I need an std::map.
 
@Olumide Use a trait.
 
4:13 PM
@classdaknok_t You could maybe step down and rely on guarantees of your platform. I'm not familiar with that though.
 
@RMartinhoFernandes Thanks.
 
@LucDanton could I start a thread and block till it returns in the signal handler?
 
That sounds... nasty.
 
Couldn't just use the handler to post some event on a queue and pick it up from somewhere not-a-signal-handler?
 
4:14 PM
@classdaknok_t The list of functions that are safe to call from a signal handler is quite short and I don't think thread-related stuff are in it.
 
Hmm…
That sucks; sig_atomic_t is int on my machine, so I cannot store a pointer in it.
 
Too late to switch to multiprocessing/Boost.Signals?
 
I'm not familiar with Boost.Signals.
I'll look it up. I am using ptrace and I need a handler for SIGCHLD.
std::map<pid_t, Session*> sessions; // Global.
void Session::set_SIGCHLD_handler_() {
  struct ::sigaction action; memset(&action, 0, sizeof(action));
  action.sa_sigaction = &Session::SIGCHLD_handler_;
  action.sa_flags = SA_SIGINFO;
  ::sigaction(SIGCHLD, &action, nullptr);
}
void Session::SIGCHLD_handler_(int signum, ::siginfo_t* info, void*) {
  // I need to access `sessions` here.
}
 
Oh. Boost.Signals can't help with that then.
 
@classdaknok_t Ew, that sound broken somehow.
 
4:24 PM
> The type sig_atomic_t is always an integer data type, but which one it is, and how many bits it contains, may vary from machine to machine.
 
woof woof!
 
@classdaknok_t Sure, but a machine where it's smaller than intptr_t makes things terribly complicated.
 
But if it's an int, I could as well use std::atomic<pid_t> I suppose. I have an infinite loop in which I could read it and if it's not 0, act accordingly.
Or multiple std::atomics.
 
How do you retrieve the Session* from that?
 
@RMartinhoFernandes Just tested, sizeof(std::sig_atomic_t) >= sizeof(std::intptr_t) fails as well here.
 
4:27 PM
What's so nasty about signal handlers that you can't have a 64-bit sig_atomic_t?
Or is this just bad QoI?
 
std::map<pid_t, Session*> sessions;
volatile std::atomic<pid_t> foo;
void bar() {
  for(;;) {
    if (foo != 0) {
      sessions[foo];
      foo = 0;
    }
  }
}
 
:3655468 Doesn't need the volatile, but needs to be lock-free.
 
Then I'd set foo in the signal handler.
 
I wrote Hello World in Java, I'm not proud of it :P
 
@RMartinhoFernandes SEH handlers are only restricted in that they cannot call alloca(), as far as I'm aware, so I'd put this one down to a bad implementation.
 
4:29 PM
Ah the good old object-oriented Hello World program from Java.
 
When the processing of the abstract machine is interrupted by receipt of a signal, the values of objects which are neither
— of type volatile std::sig_atomic_t nor
— lock-free atomic objects (29.4)
are unspecified during the execution of the signal handler, and the value of any object not in either of these two categories that is modified by the handler becomes undefined.
Dunno about, say, Posix.
 
> that is modified by the handler
I don't need to modify it.
 
But the values are unspecified.
 
Oh yeah crap. :P
 
arguably, you could create a lockless concurrent unordered map, and use that
 
4:34 PM
Have you seen new comments on that exception thing?
> uh, C++ has huge advantages. What you really want is C + two or three C++ features. or 100, really. But not exception handling, not RTTI, not STL, not all the Java-esque shit. You have to understand that the people who designed it are basically morons and the people who implemented stl are retarded morons, but underneath it all there is still C with vastly improved namespacing and data hiding.
 
@CatPlusPlus My god. This guy needs a pitchfork to the face.
 
He's really channelling Torvalds there.
 
lol, namespaces and data hiding are all the C++ goodies?
 
woah, I think this guy misunderstood the point of C++
 
@RMartinhoFernandes Also, C++ is Java-esque.
 
4:37 PM
No type named 'atomic_bool' in namespace 'std'? WTF?!
 
atomic<bool>
 
Same thing.
 
Is there any compiler that implements atomic<>?
 
@CatPlusPlus Where's that question?
 
4:38 PM
> Atomic operations Clang 3.1
Meh I have clang 3.0.
 
@RMartinhoFernandes isn't atomic_bool just a typedef for atomic<bool>
 
But it doesn't implement any ordering guarantees, so it's pretty much worthless anyway.
 
@CatPlusPlus There's also this... thing. chaoticmind.net/~hcb/projects/boost.atomic
 
@EtiennedeMartel I mean 250bpm.com/blog:4
 
> This is not going to be a Torvalds-ish rant agains C++ from the point of view of die-hard C programmer.
 
4:39 PM
@bamboon No such thing.
 
Reminds me of those guys who prefix any homophobic comment with "I have nothing against gays, but..."
 
There's atomic_flag.
 
Not the same thing.
 
what's the advantage of using std::ostream_iterator when printing an array of char to the std::cout, instead of just doing std::cout << mychararray; ?
 
None.
 
4:40 PM
That only has test_and_set and clear, nothing else. It's intended to be the most basic atomic thing, and unlike the others, it's guaranteed lock-free.
 
What'd you need from an atomic boolean?
 
hmmm alright
 
@TonyTheLion Doesn't rely on NUL-termination.
 
@CatPlusPlus I have a loop and I want to be able to stop it from another thread.
 
@CatPlusPlus Assignment without test? The two variants of compare_exchange? Exchange without test?
 
4:41 PM
@RMartinhoFernandes ? it works for me.
 
@bamboon Oh, nevermind, looking at the wrong place. You're right.
The standard doesn't list atomic_bool in the table with the others...
 
@LucDanton hah, interesting :)
 
@TonyTheLion thats what i was getting at in the comments
 
@EtiennedeMartel But he didn't make a Torvalds-ish rant.
 
4:43 PM
Linus wouldn't like this lounge one tiny bit.
 
@CatPlusPlus Initialization too: atomic_flag can only be initialized to clear. When I said "nothing else", I meant it.
 
@ScarletAmaranth Of course he wouldent, Linus wrote the kernel in C
 
@johnathon ah right
 
@johnathon Yeah he also trashtalks c++ a tad more than it deserves :)
 
@RMartinhoFernandes hey robot
 
4:45 PM
Hey.
 
are you going anywhere soon? I'mma grow some super balls and try my first branching and merging
 
I guess I need a lock-free, atomic queue.
 
and I fully expect it to go horribly wrong
and may require your assistance
 
@ScarletAmaranth LOL , well, all in all , outside kernel mode C++ is just as good as if not better than C, do a round table measurement of qsort vs sort, proof is in da puddin;)
 
An American left an unpaid ~7500€ debt in an hotel in Rio. 3000€ of those were from Caipirinhas.
@DeadMG I'm staying at work until 19-20.
 
4:47 PM
awesum
 
@DeadMG If you're using Git or Hg, there's no way it can go wrong. Unless you decided to fuck with karma this month.
 
@EtiennedeMartel Hg, and, when it comes to source control, Karma always caught me in bed with it's mother
 
@classdaknokt a lock free atomic que GOOD LUCK my friend
 
@EtiennedeMartel Oh, it can.
 
@classdaknok_t If you have a garbage collector, it's easy.
 
4:48 PM
@DeadMG Keep us updated.
 
@CatPlusPlus Stocking up on popcorn gifs?
 
well
I cloned my repo
not sure where the "branch" button is, though
 
@johnathon why outside kernel mode?
 
Hi. Any good API for WinBase.h ?
 
4:52 PM
According to linus, three reasons: (1) C++ exceptions don't work, (2) Hiding allocations, and (3) it's not needed. source. IMO #2 is the only valid reason there.
 
@MooingDuck I think this is a good overview: msdn.microsoft.com/en-us/windows/hardware/gg487420
 
@MooingDuck It isn't either. If you need to allocate, then you need to allocate. Abstracting over allocation is no different to any other kind of abstraction.
 
@MooingDuck even on windows it's recommended to not use c++ in kernel dev, it CAN be done, but it's not recommended
 
@DeadMG I had half a retort typed before I recalled that you already proved that allocation can be fast.
@johnathon why?
 
@MooingDuck The article I linked explains that.
 
4:55 PM
@MooingDuck Obscenely fast.
damn
remember what someone told me about my infrequent commit rate?
now it irks me
 
@RMartinhoFernandes reading, but the second paragraph claiming that templates are bad in the kernel is disheartening
 
@MooingDuck i think it has to do with memory organization, and byte alignment issues, though i could be wrong
 
I want to clone and then back out a couple changes and keep the rest, but now I'm doing it manually because I didn't commit them individually
 
@johnathon those are the same in C and C++ IFAIK
 
@MooingDuck It comes from MS experience, so it may be biased due to MSVC behaviour.
 
4:56 PM
@MooingDuck I'd seriously have to go consult some references to give you an accurate reason, but from what i can scantly remember, the reasons were good ones
 
@DeadMG hehe, you're learning.
The hard way.
 
indeed
but I expect that I've learned quite a lot more than most non-graduates
 
@DeadMG Most graduates I know didn't even know source control was a thing
 
This feels really bad.
while (last_info != nullptr);
last_info = info;
 
@classdaknok_t It is really bad.
you need to use an atomic function to compare, afaik
 
4:59 PM
aaarg fuck signals.
 

« first day (572 days earlier)      last day (4394 days later) »