« first day (810 days earlier)      last day (4143 days later) » 

user142019
4:00 AM
I didn't put pointers in variant.
 
user142019
I put types in there that had std::unique_ptrs as members.
 
user142019
Thus those were uncopyable.
 
@Zoidberg'-- Youre putting a copy of the type that the unique_ptr points to
thus making the unique_ptr useless, at least i think so
 
use auto_ptr :P
 
4:01 AM
@StackedCrooked Why?
(Not that it makes sense but still)
 
You might as well use dynamic dispatching then.
 
Or.. not?
 
boost variant has a performance advantage by eliminating the pointer dereference.
 
user142019
Oh right.
 
user142019
optional is not movable either.
 
user142019
4:04 AM
Stupid Boost. Piece of shit.
 
LOL
 
~performance~
 
Also, value semantics.
 
value_ptr
 
@Borgleader So you don't get called a xenophobic pig on the Internets.
@StackedCrooked Boost variant's primary motivation is about semantics.
@StackedCrooked Overlapping, but not the same use cases.
 
4:05 AM
@R.MartinhoFernandes For not using Unicode???
 
Consider boost::variant<something*,int>.
 
There is no reason to not use Unicode
 
user142019
If D derives from B, can I construct std::unique_ptr<B> from std::unique_ptr<D>&&?
 
user142019
(If I can't I'll just use new and delete and not give a fuck.)
 
@Zoidberg'-- std::unique_ptr<B> b(d.release()).
 
user142019
4:10 AM
@StackedCrooked even when I move it?!
 
Your code is terrible
 
@Zoidberg'-- Ah, you mean std::unique_ptr<B> b = std::move(d);
 
user142019
Yes.
 
That might work, not sure.
 
user142019
huh dafuq
 
4:12 AM
@Zoidberg'-- Yes, just move it (and make sure you have virtual destructors).
 
user142019
Clang tells me ctor of vector is deleted but it doesn't tell me which overload. What a terrible compiler.
 
user142019
@R.MartinhoFernandes ah thanks.
 
user142019
In file included from /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/memory:66:0,
                 from ast.hpp:3,
                 from parse.hpp:3,
                 from parse.cpp:1:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.2/../../../../include/c++/4.7.2/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<zlang::ast::statement>; _Args = {const std::unique_ptr<zlang::ast::statement, std::default_delete<zlang::ast::statement> >&}]’:
 
user142019
Beautiful, GCC.
 
user142019
Template hell.
 
4:15 AM
error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = zlang::ast::statement; _Dp = std::default_delete<zlang::ast::statement>; std::unique_ptr<_Tp, _Dp> = std::unique_ptr<zlang::ast::statement>]’
 
user142019
But it is much more helpful than clang's diagnostics.
 
You are trying to copy a unique_ptr.
 
user142019
At least GCC tells me which overloads are faulty.
 
Indeed.
 
But clang's diagnostics are soooo awesome!
 
user142019
4:16 AM
They sometimes are.
 
user142019
And otherwise they are just terrible.
 
Clang is more trendy than you'll ever be.
 
user142019
Why do I even do this in C++.
 
Because you're dumb
 
user142019
I could have done it in C and it would have been much easier.
 
4:17 AM
And here's definitive proof ^
 
user142019
xD
 
Cue cat's psyduck.
 
Do it in Wide.
 
user142019
@StackedCrooked Then I'll first have to complete my Wide implementation, or wait for the Slowpoke Puppy.
 
user142019
@StackedCrooked the copy ctor of vector tries to do that.
 
user142019
4:19 AM
Why isn't the copy ctor of vector deleted when it's used with uncopyable objects.
 
user142019
And why does it even call the copy ctor.
 
user142019
WTF.
 
I suspect noexcept.
 
user142019
Ohh.
 
This would be cool:
variant->foo(); // SFINAE checks that at least one type is contained that supports this method. plus runtime check.
 
user142019
4:23 AM
The only member of module is std::vector<std::unique_ptr<statement>> stmts; and statement is an abstract class with only a pure virtual dtor.
 
user142019
And it tries to call copy ctor of std::vector. Should I make move ctor of statement noexcept then?
 
That is not called.
 
user142019
Oh.
 
Are you sure you are requesting a move of the vector?
 
user142019
Well, I'm requesting a move of module.
 
user142019
4:25 AM
struct module final : node {
    std::vector<std::unique_ptr<statement>> stmts;
};
 
That's not the important part.
If you try to copy the module, it won't move the vector. Obvious reasons.
 
user142019
I have an ast::module module; and some time later I have return module;.
 
user142019
zlang::ast::module zlang::parse(std::string code) {
    class lexer lexer{std::move(code)};

    ast::module module;
    try {
        for (;;) {
            auto tok = *lexer;
            switch (tok.kind) {
                case token::IMPORT:
                    module.stmts.emplace_back(parse_import(lexer)); break;
            }
        }
    } catch (std::out_of_range const&) {
        return module;
    }
    return module;
}
 
@Zoidberg'-- 'it tries to call a copy', the mistake seems to be at the calling site
 
I would want to work with sbi in Berlin, but I don't know German and I don't think he'd take a young spritely fellow like me under his wing. I'd probably get on all of his nerves. :c
 
4:28 AM
lolwut if there are too many statements you just proceed as if nothing happened?
 
user142019
No if the lexer has reached EOF.
 
user142019
I should use something else for that, really. :P
 
You throw out_of_range for that?
 
user142019
Well I use std::string::at() in the lexer. xD
 
Ewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww.
 
4:29 AM
Also, just a quick question. Seeing that code, what's the for (;;) { in there for?
 
Shouldn't it be: auto tok = *lexer++;
 
Can't you just use a while(true) ?
 
user142019
No.
 
Just make the output of the lexer be a range (ranges have a natural end).
 
user142019
@StackedCrooked operator* is peek, operator() is increment and peek.
 
4:30 AM
@ThePhD Reading forever (well, until the silly exception is thrown).
 
Also (;;) looks like Zoidberg.
 
user142019
@ThePhD for (;;) is similar to while (true).
 
for (;;) is more idiomatic IIRC.
 
Idio... what?
Oooh.
It's more language-natural.
 
13
Q: How can I learn to write idiomatic C++?

yati sagadeI am a computer science student, and as a result, I was taught C++ as a better version of C with classes. I end up trying to reinvent the wheel whenever a solution to a complex problem is needed, only to find sometime after that, some language feature or some standard library routine could potent...

 
user142019
4:34 AM
Dammit.
 
user142019
Dear compiler, I swear to you I don't copy that vector.
 
user142019
Please.
 
Idiomatic can be explained as: When in Rome, do as Romans do.
 
Ah.
When in the lounge, for ZOIDBERG { }
 
user142019
Why doesn't the fucking compiler tell me WHERE I copy that fucking module.
 
user142019
4:35 AM
WTF is this.
 
It's your code :p
 
user142019
But WHERE in my code.
 
is it a vector of unique_ptr?
 
user142019
Yes.
 
Are you using incomplete types in the declaration?
 
user142019
4:38 AM
Well.
 
user142019
Yes. XD
 
It's pretty unexpected. Took me a while to figure it out.
 
user142019
But that doesn't make any difference.
 
But it was the only thing I thought I could help with :)
 
user142019
But I think I should do all the dtors in the .cpp file.
 
4:40 AM
You're on your own. Gl.
 
GI Joe?
 
'MURRICAN HEEEEE ROOOOOOOOOH.
 
@StackedCrooked Nah, 'tis the font.
 
user142019
4:55 AM
Fuuuuuuuuuck.
 
user142019
Can I tell GCC to put an empty line between every diagnostic?
 
user142019
This is unreadable as fuck.
 
cpx
@abhinav: Our flair is quite similar :)
 
user142019
The diagnostics from GCC are an unreadable mess straight from template hell.
 
cpx
4:59 AM
Does it have to do with the hash of email address or something?
 
user142019
;_;
 
user142019
FUCK COMPILERS
 
user142019
T_______________T
 
user142019
What the fuck is wrong with this.
 
@cpx: I thought it was the default flair
 
user142019
5:01 AM
Why is it trying to copy a fucking vector.
 
user142019
I never copy anything.
 
you have got me thinking though :-)
 
user142019
Probably terrible useless noexcept restriction some idiot put on std::vector.
 
cpx
If you change your email address, you'll get a new flair.
 
user142019
Why can a move ctor even throw.
 
user142019
5:02 AM
It doesn't make sense.
 
user142019
Is this also the case with deque?
 
user142019
Even std::list WHAT THE FUCK.
 
user142019
Ah well.
 
Why have I decided to put non-specialized templates in the .h and specializations in the .cpp? Does that solve some problem I can't think of atm?
 
user142019
Then I'll just make all fucking move ctors noexcept = default.
 
5:09 AM
who should I draw to test my algorithm?
 
Zoidberg.
 
Kay
I can draw that in two contour lines so it'll be super simple
 
user142019
5:31 AM
What the FUCK.
 
user142019
FUCK C++.
 
user142019
What a terrible language.
 
user142019
C++ is a terrible, unparsable, unimplementable, overly complex, over-engineered, unusable, idiotic piece of junk.
2
 
user142019
I'm rewriting this compiler in C.
 
user142019
It's much better and doesn't get in my way.
 
5:37 AM
Two days from now: "FUCK C. What a terrible language. C is a terrible, unparsable, unimplementable, overly complex, over-engineered, unusable, idiotic piece of junk.
I'm rewriting this compiler in Haskell."
 
user142019
C is simple and easy to use.
 
user142019
I never had any problems with C.
 
user142019
With C++ I always had problems because of all the implicit shit.
 
user142019
C doesn't copy objects when I don't tell it to.
 
user142019
C++ does.
 
5:39 AM
Considering that C doesn't have objects...
 
user142019
What are you smoking?
 
user142019
Of course C has objects.
 
user142019
struct foo foo; // here, an object
 
Can you define methods?
 
user142019
No and how is that relevant?
 
user142019
5:40 AM
In C++ an int is also an object, just for your information.
 
user142019
It has no methods either.
 
user142019
And you cannot define methods on it.
 
user142019
Nor derive from it or do anything.
 
Why is it an object then? #define type object?
 
user142019
Because the standard says so.
 
user142019
5:43 AM
> An object is a region of storage.
 
That's not the OOP meaning of object.
 
user142019
Who the fuck cares?
 
so problem solved
 
user142019
I'm talking about C and C++.
 
user142019
And in the C and C++ standards, an object is a region of storage.
 
5:44 AM
we were talking about different things this whole time
 
user142019
And that includes primitive types and structs.
 
@Zoidberg'-- rvalues
 
user142019
Irrelevant.
 
@AndreiTita Yes.
 
user142019
It implicitly copies my objects because the move ctor may throw (guess what: it never will).
 
5:50 AM
@AndreiTita I'm pretty sure that's a terrible idea, because specializations won't get used properly
 
@MooingDuck I'm declaring them ahead.
 
@Zoidberg'-- say what now?
@AndreiTita oh, then that's not a bad idea. works fine.
 
user142019
std::vector and noexcept
 
@R.MartinhoFernandes I'm glad you agree with me, but I'm not sure on what.
 
Yes, you can define methods on C objects.
Don't be fooled by syntax, but WriteFile is a method of file objects.
 
5:52 AM
@Zoidberg'-- in most cases, C++ and C do copies in all the same places. Sounds like you don't know how to C++.
 
@R.MartinhoFernandes I know that. But it's not built in the language. You can write code to do OO-stuff in C (including virtuals), but the language was not designed to support that implicitly.
 
@Zoidberg'-- unique_ptr move ctor does not throw.
 
@Zoidberg'-- though I don't yet understand what noexcept has to do with anything
 
user142019
@MooingDuck std::vector refuses to move objects if their move ctors may throw.
 
@Zoidberg'-- I'm pretty sure that's not the case
 
user142019
5:54 AM
Well, that was the case.
 
user142019
And that caused all the trouble.
 
1 min ago, by R. Martinho Fernandes
@Zoidberg'-- unique_ptr move ctor does not throw.
 
user142019
And the unreadable diagnostics caused by C++ being an unimplementable piece of junk.
 
user142019
@R.MartinhoFernandes not unique_ptr; a class containing one single member of type unique_ptr.
 
5:55 AM
@Zoidberg'-- The compiler generated ones have the right noexceptness.
 
user142019
Not my two compilers.
 
@EtiennedeMartel What the.
 
@AndreiTita Macs were so cool back in the day.
 
user142019
Whatever.
 
user142019
I'll just stop using C++.
 
user142019
5:56 AM
I hate it.
 
wait, that makes no sense
 
@MooingDuck Are you sure that it makes no sense?
 
moving a vector shouldn't have any requirements on the underlying type, since it doesn't do anything with the underlying type.
wait, I get it, you're not moving the vector. duh.
 
With throwing moves it is impossible to hold stronger exception safety guarantees.
 
ah, vector.erase is nothrow, so if the move isn't nothrow... wait, how does that work...
 
6:00 AM
noexcept doesn't actually impose compile-time constraints does it? Because I'm pretty sure I've read somewhere that if an exception is thrown in a noexcept function, the program will terminate.
 
@AndreiTita sounds right
 
libstdc++ vector will use copies if the move throws, or just bite the bullet and move with poor exception safety if the the type is move-only.
There is also std::move_if_noexcept specifically for this.
 
why the frick is vector::erase marked as not throwing exceptions in the spec? deque doesn't have this issue.
 
user142019
if (identifier_length == identifier_capacity) {
    identifier = realloc(identifier, identifier_capacity *= 2);
}

identifier[identifier_length++] = c;
c = state->text[++state->index];
 
user142019
Isn't this beautiful. XD
 
6:06 AM
@MooingDuck It isn't.
 
deque: Throws: Nothing unless an exception is thrown by the copy constructor, move constructor, assignment operator, or move assignment operator of T.
vector: Throws: Nothing.
 
> Throws: Nothing unless an exception is thrown by the copy constructor, move constructor, assignment operator, or move assignment operator of T.
 
@R.MartinhoFernandes not nothrow, simply not throwing
@R.MartinhoFernandes § 23.3.5.4/4?
 
Waaah classes again
I DON'T WANNA
 
@MooingDuck That's for list.
 
6:07 AM
14
Q: Can vector<T>::clear throw?

smallBIs there any chance for a call to std::vector<T>::clear() to throw an exception?

 
@R.MartinhoFernandes oops
 
Silly duck.
 
It doesn't explain the reason behind the standard, though.
 
@AndreiTita clear isn't the same
 
@MooingDuck I think the first answer pretty much lists all the methods that can't throw (all)
 
6:08 AM
@R.MartinhoFernandes Why would it do that? Why not move anyway?
@AndreiTita there are many other members that can't throw as well. begin()
 
@MooingDuck Because if a move throws halfway you are left with two half filled arrays.
There is no way to recover from that.
 
@R.MartinhoFernandes ah, makes sense.
@R.MartinhoFernandes never heard of that. researching
 
user142019
segfault xd
 
@R.MartinhoFernandes did you guys notice I was gone for two weeks?
 
@MooingDuck You warned.
@AndreiTita The reason is that clear only needs to call destructors and the standard library just tells you to fuck off if your destructors throw.
 
6:10 AM
@R.MartinhoFernandes that's pretty neat
 
@R.MartinhoFernandes Cheers.
 
@R.MartinhoFernandes I've been thinking about that recently, and came to the conclusion that stack-unwinding-exception-handling is a stupid thing.
Exception handlers should be functionoids somehow (obviously, not C++ anymore)
 
@MooingDuck Not sure what you mean.
@MooingDuck Ah, that.
 
I haven't worked out any details, but I think it makes more sense.
 
You need to unwind the stack anyway, though.
 
6:13 AM
The only unwinding thing is basically an OPERATION_FAILED, which you can catch to either continue anyway, retry, or otherwise you get it propogate up, maybe to abort.
it doesn't even need data or to exist as an object, since any handling should have taken place before unwinding, so it doesn't matter what the cause was.
 
I think std::throw_with_nested(std::shit_it_the_fan_badly()) is a good enough policy, maybe better than std::terminate.
@MooingDuck You don't want that.
 
@R.MartinhoFernandes no?
 
What if an exception was thrown with a lock held somewhere? Do you want your handler to run while the lock is still held?
That makes for very hard to write handlers.
 
@R.MartinhoFernandes yes it does
 
Unwinding first guarantees you some semblance of sanity when the handlers run.
 
6:18 AM
@R.MartinhoFernandes also a good point
oops, already reached that conclusion already
it also complicates "retry under this one condition"
I think the goal was to make new nothrow, but it doesn't actually accomplish that. But it makes it possible to make new able to release unneeded resources, and try again.
 
I don't claim I have a better solution, (and I think I told you this before), but this is a very sensitive part of the language and touching it requires a lot of very careful thought because it is easy to break things with small changes.
 
yeah, I wouldn't do that to C++, it's way too big of a change.
enables a couple other neat tricks
 
That said, the fact that exceptionceptions std::terminate doesn't really bother me because I don't think you can keep sanity when cleanup fails.
 
@R.MartinhoFernandes oh right, I remember the reason. Reporting a failure if closing a stream causes a flush which has an error.
exception handlers as callbacks make that a non-issue
wheras stack unwinding makes it impossible.
@R.MartinhoFernandes also callbacks allow retrying of cleanups.
 
@MooingDuck And so do explicit cleanup functions.
 
6:26 AM
@R.MartinhoFernandes takes extra code
 
Two lines?
 
eh, true enough
wife is home and apparently it's talky time. Later.
 
Have fun. hehe
 
Went to Netflix, sort by best rating for me... this happens
user image
2
 
Trust your Netflix overlords?
 
6:32 AM
> Google chairman Eric Schmidt is heading to the least internet-friendly county on the planet, according to AP, with a forthcoming trip to North Korea on his schedule.
 
All my top ratings are cartoons and nature documentaries
 
In the last video, STL mentioned something about the One Definition Rule being a "scary" area of C++. Any idea why?
 
It's full of "no diagnostic required" for one thing.
 
It leads to linker errors which are not reported.
 
Ah.
 
6:34 AM
Happened to me once when I was oblivious about the ODR. It was the most frustrating debugging session in my life :)
Nothing made sense.
Bottom line was: always use anonymous namespace when defining new things in a .cpp file.
 
user142019
I have to implement a hash table in C!
 
Kids say the darndest things ;)
 
I like the fact he's oddly enthusiastic about it :)
 
Pro-tip: he's nuts.
 
@sehe lol
morning everyone
 
user142019
6:40 AM
Almost got my lexer done!
 
Mornin'.
 
implement me in c
We need a C implementation of Crowz
 
user142019
@Crowz int main() { void *foo = NULL; *foo; return 0; }
 
1998 called. They want their return 0 back.
 
user142019
s/1998/1989/
 
6:53 AM
Only C99 does not require it.
 
user142019
7:13 AM
Neither does C11.
 
7:32 AM
Recruiting from this chat is recipe for getting nothing done
That btw that pin
 
I'm gonna ask about it.
I'm not entirely positive, but I think I've implemented a draw mechanism in precisely the most idiotic way possible.
Nah, nevermind. It makes some sense to do it like this.
 
7:56 AM
@CatPlusPlus You just noticed?
 
8:27 AM
dat silence
 
good morning
 
lol
mawning
 
I keep trying to implement policies/strategies with boost variant. This is my last attempt thus far.
 
Modulo has the same priority as multiplication right?
(Not even sure why I'm asking that. I think I've used that assumption multiple times already)
 
8:43 AM
morning all
 
@AndreiTita Yes
 
Cool.
 
by 'rather leisure definition of "good"' does @sbi basically mean 'can do stuff in C++ but is not one of those autistic people who know off by heart'?
 
Hilariously I needed to add some parantheses anyway, so it was completely moot.
 
@thecoshman He probably means "Don't think you're bad just because you're not as good as @R.MartinhoFernandes".
 
8:46 AM
@EtiennedeMartel people think the robot is good as C++? sadly for him, there is more to C++ the TMW :P
 
Template Meta Wankery
3
obviously :P
 
Yeah, I guessed as much.
 
I love template wankery
 
8:48 AM
I have several templates that I use for wanking.
 
Me too. It's the closest I have to a guilty pleasure.
 
ohai
so I guess Book<C++> isn't ever really gonna happen, is it?
seeing the reputation of us getting stuff done in this room...
 
@TonyTheLion we get stuff done, just not the stuff we set out to do
start making group game -> start making low level libraries -> start making build system
 
ahahahah
 
true story
 
8:52 AM
#pragma warning(push) <-- dafuq does this do?
 
push a warning obviously
 
pushes the warning settings
 
push it where?
 
on a stack somewhere
then you can alter the warning settings (disable some etc)
 
rectally not too sure
 
8:53 AM
then you can repop the previous settings when you're done
 
aka you can write code that stops the person compiling being able to check for idiot mistakes?
 
so it saves some current settings -> alters the settings -> pops off the original saved settings
 
It might be a rectal stack. Ask your compiler vendor.
 
@thecoshman Rectum.
 
8:54 AM
yo momma
 
(I like when things are obvious)
Innuendo is for the weak.
 
@thecoshman "the person compiling" - interesting concept. I usually have my computer do the compiling, though.
 
@EtiennedeMartel I knew the word, just being coy
 
@EtiennedeMartel You're up late today?
 
I was about to go to sleep, actually.
But yeah, I'm still on vacation.
 
8:55 AM
ah
 
@AndreiTita the compiler does not care about idiot mistakes, I do though
 
You need to improve your relationship with your compiler then. Your compiler would care about your little idiot mistakes, if only you'd open up to it. Your compiler WANTS TO LOVE YOU.
 
it aint going to care about shit when twat code can override your flags and use bullshit code
 
lol
> twat code
 

« first day (810 days earlier)      last day (4143 days later) »