« first day (514 days earlier)      last day (4417 days later) » 

12:10 AM
Kids, putting all the code in the same file is a bad idea. Especially if you don't keep any particular order on the things you put there.
 
Can't imagine what compilation times would be if I'd do that.
 
@LucDanton Oh, GHC is fast.
The problem is me.
 
Xeo
Did you know that Clang actually supports modules as an experimental extension?
 
So, you complain about no modules for C++ and when you do use a language with a great module system you ignore it?
 
@LucDanton I'm growing this organically. I think it's time to have carve modules out of it now. I didn't think so before (putting one function on each module doesn't really bring a lot of benefit...)
 
12:14 AM
You're wrong. Modular code is awesome.
 
wtf's up with all the flags?
 
@LucDanton It's overkill if it fits on one screen.
And I'm on a clock, so I'm not taking time for overkill.
 
I disagree.
 
@DeadMG Amazing.
 
Although I do tend to write above main first, then move the code someplace when it makes sense as a unit. (I've said this before I think.)
 
12:17 AM
"someone has sand in their vagina" - wtf? ok, i voted "not sure"
 
The point is though, I don't do this with multiple things at once. I only grow one feature at a time. Makes it easier to get a sense of dependencies.
 
@LucDanton That's exactly my plan.
 
@CheersandhthAlf Oh.
 
Obviously though you're right that the time limit puts a spin on all that.
 
I do agree that I let this go on for a bit too long. (Which was the thought that inspired the comment above)
 
12:21 AM
@RMartinhoFernandes Btw you're the one that suggested Boost.uBlas as a vector library?
 
Depends.
General linear algebra, yes.
 
Initialisation of its types is a bit painful :(
 
I dislike when there's a guy who's hit by the XY problem, posts a bad question, and then people go on and put "answers" which are basically just "it works on my side, please precise your question".
0
Q: Getting comparison between ! and user input

Eric BanderhideI'm not sure why this is causing me trouble, I think I did it earlier in a test and it worked fine. I get some user input using cin then pass this to another method as a char. I then just wanted to say: if(userInput == '!'){ //do Something } But it didn't get it, so I tried defining a c...

Case in point ^.
 
For the 3- and 4-vectors, and 4x4 matrix kind of math used in games, GLM is sweet.
@EtiennedeMartel Flag 'em.
Woah, three of them? Ow.
 
Do people just pull stuff out of their asses or what?
 
Xeo
12:26 AM
@MooingDuck: Mind if I fix your code?
 
@RMartinhoFernandes Initialisation does look nicer, I'll give it a try.
 
Damn, having to find a decent seed for testing is annoying.
 
Xeo
@RMartinhoFernandes Yay, free flagweight
 
Flag as what, 'not an answer'? Oh, you've commented to that effect.
 
@Xeo You still don't have the badge?
 
Xeo
12:29 AM
Nah
I'm lazy with my flagging
Though I could get it with a full day's worth of flags
I'm at 450 now IIRC
 
I thought you were very close.
 
Xeo
Fuckload of flags in the chat, wtf.
 
it's a whole bunch of LMGTFY links
 
Kids playing on the JavaScript room.
 
Xeo
0
A: What is the equivalent of the C++ Pair<L,R> in Java?

MatunosJakarta Commons Lang 3.0+ has a few Pair classes: http://commons.apache.org/lang/api/org/apache/commons/lang3/tuple/package-summary.html

Class Summary
ImmutablePair<L,R> 	An immutable pair consisting of two Object elements.
MutablePair<L,R> 	A mutable pair consisting of two Object elements.
Pair<L,R> 		A pair consisting of two elements.
So, are the elements in the last pair mutable or immutable?
Or should it be called SchrödingersPair<L,R> since they're both at the same time?
 
12:34 AM
C# has Tuples.
But since generics are not variadic, you're limited to 8-tuples.
The workaround for larger tuples is to stick another tuple on the last element.
 
Xeo
Hm.. I'm wondering, since I read in one of the links you gave me for monads, that exceptions are actually a pair<R, optional<string>> in Haskell, could a pair also be seen as a monad? (cue: Monad ALL the things)
 
I think a pair with the first type fixed can be one.
@Xeo No, you can't monad all the things.
Which brings us to arrows...
 
Xeo
Another easy topic? :D
 
I've played with arrows a while back, didn't really see any obvious advantages to them
 
Xeo
12:40 AM
Go go, tell me what arrows are and why you need them.
I'm in for easy topics today.
 
> Arrows, or Freyd-categories, are a generalization of Monads.
 
@Xeo I'm not entirely sure I can do that.
@Pubby They're a lot less intuitive too.
 
Xeo
I just noticed that one of my 10-vote answers is, effectively, not an answer. :( stackoverflow.com/a/6561730/500104
@RMartinhoFernandes Monads.. intuitive... yeah.
 
@Xeo They are!
 
@RMartinhoFernandes Yeah, I doubt I would have "invented arrows myself"
 
12:42 AM
@ScottW lol
 
I have ctor init lists that are like 10 lines long each. Is there any way to avoid this boilerplate?
 
Xeo
Don't put so much stuff in your objects?
 
Most of it's just like foo(other.foo) or foo(0)
 
Are you writing copy ctors by hand?
 
Xeo
Value init, generated copy ctor
 
12:45 AM
I try to use constructor delegation such that I limit the numbers of valued constructors that actually use init lists for the members.
 
@RMartinhoFernandes I have to write one in this case
 
@Pubby int foo = 0;
 
Xeo
@Pubby Then you're doing it wrong, surely?
 
Oh yeah, and in-class initialization + T() = default; is a relief, too. Screw being opaque. And modularity.
 
@Pubby Can't you encapsulate the small part that needs special treatment, and write a copy ctor only for that part?
 
12:46 AM
@RMartinhoFernandes How does that work? Put the rest in a struct?
 
That can work if you actually want value initialisation for, say, POD types.
struct big_lump { int foo; long bar[lots]; }; then just have : my_big_lump {} in the init list.
 
I was talking about putting that special-needs part alone in a struct.
 
Here's the code I'm talking about: pastebin.com/BsG3T90P
 
We can't see what the members are.
 
Xeo
I see malloc the first thing I open the link. DO YOU WANT TO KILL ME?!
 
12:48 AM
@Xeo Phew, I'm glad I didn't click it, then.
 
Xeo
But it seems to be a smart pointer atleast
 
Instead of struct my_thing { int a_member; int another; raw_handle special_needs; /* painful copy ctors and friends follow */ };, you do struct my_thing { int a_member; int another; handle no_special_needs_anymore; }; struct handle { raw_handle special_needs; /* now easier copy ctors and friends */ }.
That could have used better formatting...
 
@Xeo I need to use some realloc
 
char_type* lptr, rptr; uh...
 
12:49 AM
Ooops.
 
Xeo
@LucDanton Uh oh
 
@LucDanton Ha, didn't catch that
 
Xeo
Never declare two pointers on the same line.
Star that, bitches!
 
char_type* lptr,
    rptr; // Yep, much better
 
@Pubby Make the memory buffer be an object on its own that handles the memory parts. Then you don't need to drag all the other members when copying.
 
12:50 AM
@Xeo I should flag it for being a generalization!
 
Xeo
@LucDanton lol
@LucDanton Starring that actually kills the pun
 
@RMartinhoFernandes The problem is that most of the members have to be updated when I resize
 
@Xeo Aye, no regrets.
 
@Pubby Resizing doesn't happen on copies, does it?
 
@RMartinhoFernandes Well I just have to keep the pointers correct
 
12:52 AM
In this instance, would writing an allocator that uses malloc/free a) work b) not be overkill? Then, std::vector time.
 
Oh, my copy constructor didn't update them x_x
 
@LucDanton The allocator model doesn't support realloc.
 
I need pretty tight control over the allocations, don't think vector will provide that
 
@RMartinhoFernandes Well I took that he needed realloc for another API. I may be remembering a previous discussion.
Oh okay my bad, mixed up things then.
 
12:54 AM
I'm actually only calling realloc in certain circumstances - the problem is that I need to do a special copy instead of just a single memcpy
 
Xeo
@Pubby What's so special about that copy?
 
Well it's for a gap buffer. Their are two segments that get copied and both are at opposite ends
 
I don't think I have any comment to offer on your constructors/members. I can't get a feeling of the semantics of the members. Sorry, I'm not at my best right now. I needs food badly.
 
Another thing I already knew but ended up learning anyway with this roguelike project is that you should never mix two coordinate systems.
 
Don't worry though, I get that same feeling for my own code right now. So it's the hunger, not your code.
 
Xeo
12:57 AM
Question: What is a gap buffer good for?
@RMartinhoFernandes Oooh, the joy.
 
I think I will post on code review a little later. @Xeo text editing.
 
Xeo
Why not two different types? Haskell is strongly typed, IIRC
 
In this case, it's just a simple (x,y) vs (y,x), but it's generating bugs at every turn. Luckily, I can quickly find out what they are and where to fix them.
@Xeo Because I made a mistake and just went with naked pairs...
Yes, I should have used separate types.
 
But in Haskell newtype Foo = Foo Bar counts as excessive boilerplate when not going for an opaque type right?
 
The boilerplate only arises when you need to write all the class instances the original type supports.
That can THed out, though.
 
1:00 AM
Ah neat, there's libglm-dev available.
 
Xeo
@RMartinhoFernandes Next easy questions: What are typeclasses?
 
I suppose that's a package name.
@Xeo You can probably think of them as concepts until you know more Haskell.
 
@RMartinhoFernandes Yes. Copying a header would be so much trouble, so that's a relief.
 
I found type classes easiest to understand by understanding the type system
 
Ok, up/down stairs implemented. Time to eat something before I start chopping off modules.
 
1:03 AM
I'll take that in the process of carving modules in your mess of a code you needed to carve stairs too, and I'm not letting you make me think otherwise.
 
From MSDN:
> TMPF_FIXED_PITCH: If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very carefully that those meanings are the opposite of what the constant name implies.
2
 
Xeo
oh boy
MS sillyness again.
 
We need to start a list of these Microsoftisms
 
It's an easter egg to make sure you read the docs, to distinguish the good coders from the coders in a hurry.
 
1:05 AM
wow, nice... lol
 
@LucDanton Hey, it's not that messy. Well, if you discount that place where I'm not using the Game monad for inexplicable reasons.
 
@RMartinhoFernandes Your words, including just these.
 
Xeo
@LucDanton Reminds me of the intentional compiler errors in the eAthena sources to make sure you actually read the documentation before jumping into the code.
@RMartinhoFernandes Game monad?
 
@Xeo Usually, you build one monad out of several others and then work always inside that one monad. It's basically a combination of IO, the State monad, and the Maybe monad (though Maybe should probably be Error...).
 
Xeo
1:08 AM
@RMartinhoFernandes Ah, right, the exception monad was called Error
 
Oh, and what's the easiest way to replace the pointer of a unique_ptr?
 
Xeo
.release(); .reset(new_ptr);
 
I mean without freeing
 
release it first.
 
Yeah, that's what I'm doing, although it seemed kind of hacky
 
1:12 AM
It is hacky.
 
Xeo
Normally, you shouldn't need to release the pointer
 
You want the unique_ptr to give up ownership. That's hacky.
 
Well I'm using it with realloc. Hacky hack!
 
@Pubby that's not hacky
 
@SethCarnegie ?
 
Xeo
1:15 AM
template<class T, class D>
T* magical_pointer_switch(unique_ptr<T, D>& up, T* p){
  T* pp(up.release());
  up.reset(p);
  return pp;
}
There, not so hacky looking anymore!
 
Heh, I'll use that if I need to use it in lots of places
Hmm, "understand by understanding" "use that if I need to use it"
I've been speaking the way I've been writing code :(
 
Xeo
But the move assignment operator of unique_ptr amazed me with its simpleness. this->reset(other.release());
 
@Xeo Except the name looks super hacky.
> Oh, I forgot to mention – the code is like a plate of spaghetti. With another plate of spaghetti upside down on top of it. Spaghetti sandwich.
 
1:38 AM
Hm, pizza flavored chips.
 
@RMartinhoFernandes Ah, using GLM entails using floating-point types in terms of the GLSL specs, which I'm not familiar with. Is that important?
 
@LucDanton Think not. It uses float and double.
(And a custom half type if you're into that)
 
@RMartinhoFernandes Like mediump is float and highp is double? What does that depend on anyway?
 
No. highp is float for vec3 and double for dvec3. mediump is emulated lower precision.
I think.
 
1:44 AM
Well hello.
 
Oh, I can use static_assert to document my assumptions about glm::vec3::value_type anyway. I'll learn how to configure later. Neat.
@RMartinhoFernandes Alright, I got the convention of [d|i|u|b]vec3 and other types.
Is it worth it to read the GLSL specs to learn how to use the types of GLM or should I dive into the source? The code seems really neat and readable.
 
Yes, it is really neat and readable :) And uses C++11.
I didn't spend much time learning it because I picked up from GLSL.
It usually works as you would expect.
 
Okay. It's a bit weird learning from the source as the library's goal is to match the specs but I'm guessing they don't put a member unless it's expected, as you put it yourself.
 
Does anyone know how to see the calling function in debug mode in micrrosoft visual studio? ( I had an errror thrown and it's a commonly called func)
 
Well, you can also learn from the docs...
Not perfect, but they're a good start.
 
1:54 AM
@RMartinhoFernandes How do i do this?
 
That was meant to @Luc.
Oh, I was not talking to you sorry.
 
@RMartinhoFernandes I got the impression that e.g. there's no documentation regarding the vector types other than "please defer to the GLSL specs".
 
@LucDanton Ah, that's possible.
At least for the core functionality.
 
Hence my original question: to know what glm::vec3 v(1.); does, do I check the GLSL specs or the code?
Okay, same as glm::vec3 v(1., 1., 1.);. Guess I'll stick to the code.
 
Xeo
Oh hey, I just read about an interesting little device called Raspberry Pi. It's basically a really small ARM/Linux PC for ~$35
 
2:00 AM
@LucDanton Ah, sorry if I had you running in circles. I'd recommend the code. The spec is a bit on the large side and deals with lots of irrelevant things (the graphics pipeline and stuff).
 
No problem, I asked the question and went into the code right after.
 
Xeo
Will it blend?

Yes. We have conducted extensive virtual simulations. No Raspberry Pis were harmed in the testing.
 
Hello.
 
Hi
 
@RMartinhoFernandes Aw, no operator/ cramps my style as I'm using Boost.Units :(
 
2:09 AM
Is anyone familiar with Qt?
 
I suppose I could bring external operators into scope and have them defined in terms of compound assignment (which are there)... The levels of wrong are high though.
 
@LucDanton Oh, really?
That's weird.
 
Let me check the extensions.
Nope.
 
I don't remember having to multiply by reciprocal in GLSL.
I don't remember needing division either though, so it could be related.
It's really strange that /= exists though.
 
@RMartinhoFernandes Well, there's no operator* either lol.
There's a 'verbose operators' extension that brings add, mul and friends.
 
2:15 AM
I'm pretty sure scalar * vector exists.
 
> Use words to replace operators.
But where are the operators!
 
And GLSL even has memberwise vector*vector.
 
I see, it uses SFINAE to match the value_type exactly.
 
Has anyone ever seen a library that does units at runtime? So, for example, you could say, Unit(1,meter) / Unit(1,second), and it would result in something like Unit(1,meter_per_second). But these would all be of the same class.
 
2:17 AM
Oh yeah no, glm::vec3 {} * 4. is a deduction ambiguity.
 
Seems like the declaration is missing from the header, and it only appears in the .inl...
 
@RMartinhoFernandes Those are included by the headers, otherwise nothing would work.
@BenjaminLindley Boost.Units exists, although I think your 'these would all be of the same class' requirement is a tall order.
 
@LucDanton Sure, but I'd expect a declaration in the .h.
@LucDanton Always needs the f. That's actually to match GLSL's behaviour of no implicit conversions.
 
@RMartinhoFernandes Alright. Not sure how to fix that though, I'm not sure I want to use std::chrono::duration<float, std::ratio<1>>.
 
@LucDanton dvec3?
 
2:20 AM
@Benjamin Lindley, that would be much more simple that he implementation at compile time, and at the same time mush less useful. The idea is that the library can ensure at compile time whether you are doing the right operations. Somehow like when you were at school and carried the units to check that the operations were correct
 
I have an API expecting float so let me check how getting back to float works.
 
Oh.
Sounds like it is going to get messy.
 
Xeo
@DavidRodríguezdribeas Thanks for stealing my words. :P
 
@RMartinhoFernandes Meh, if &to_vec3(dv)[0] works then I'll stick with that.
 
Xeo
@LucDanton That would effectively take the address of a temporary, wouldn't it?
 
2:23 AM
@DavidRodríguezdribeas I don't think it would be less useful. I think it would serve a different purpose. It would make it very much easier to implement a kind of calculator that keeps track of units, the way Google calculator does, for example.
 
@Xeo Assuming subobjects of a temporary are temporaries (I can't recall, but that's likely the case), yes.
 
Xeo
@BenjaminLindley Stick an interface on top of Boost.Units.
 
@Xeo Isn't boost.units compile-time?
 
@BenjaminLindley That's fairly easy to do, then. You need a double (or maybe std::complex<double>) for the value, and a std::array<int,5> for the dimensions.
addition operators would assert the dimensions are the same
multiplication would return the sum of the input dimensions
 
@BenjaminLindley Boost.Units isn't a very good fit for that then.
 
Xeo
2:26 AM
@RMartinhoFernandes Sure, doesn't hinder your from actually sticking an interface on top of it. It's just very... messy.
 
@Xeo Erm, it brings nothing to runtime.
 
Well, you can use parts of Boost.Units to e.g. store dimensions. Like Ben described.
 
It's useless for this use case, by design.
 
@RMartinhoFernandes Not true.
 
you can use identical design, but 5 int template arguments are in no way compatible with std::array<int,5>
 
2:28 AM
@LucDanton "very little"?
 
Xeo
@RMartinhoFernandes Sure, just switch the underlying implementation when doing the arithmetic
 
I agree with Ben, simple is always better, and bringing a whole compile time library to disable the compile time checks... It is surely simpler to do that at runtime directly.
 
@Xeo I don't follow.
 
@BenVoigt Yes, that's very clever. Much more clever than what I was thinking.
 
Quiz question, what does the following code do:
int f( int n ) {
if (n) return 5;
static int x = f( n-1 );
return x;
}
int main() {
std::cout << f(10);
}
 
2:33 AM
Not compile!
 
Add the appropriate includes :)
 
Xeo
I'll bite - it prints 5
 
Invokes UB.
Oh, it doesn't. I'll go with 5 as well.
 
Xeo
2:35 AM
Does print 5 with Clang atleast
 
IBM and Sun agree with you. I have to check the standard, but if you want to try with your favorite compiler...
 
Xeo
GCC agrees too
 
Surely you mean favourite Standard?
 
so what was supposed to be the tricky part?
 
What version of gcc?
 
2:36 AM
Seemed really obvious to me.
 
Xeo
@DavidRodríguezdribeas The standard says the static local variable is initialized the first time control runs through its declaration.
 
the non-integral constant in the static initializer?
 
Xeo
It never does, so it never recurses
 
@DavidRodríguezdribeas 4.8 and 4.6.
 
"Except for objects declared with the constexpr specifier, for which see 7.1.5, an initializer in the definition of a variable can consist of arbitrary expressions involving literals and previously declared variables and functions, regardless of the variable’s storage duration."
I see no problem here.
 
2:38 AM
Well, visual studio prints 0, clang++ 3.something deadlocks same as gcc 4.5, gcc 3.4, 4.4, 4.6 throw an exception and HP UX compiler aborts
 
@DavidRodríguezdribeas GCC 4.6.3 prints 5.
 
what optimization level?
maybe an optimizer trying to inline, perform reduction, etc?
 
Xeo
@DavidRodríguezdribeas Eh, Clang ToT prints 5, as I said.
 
@BenVoigt None, and O3.
 
I tried gcc 4.6 on Cygwin, and it deadlocked (no optimization). John Lakos asked me that on friday, claiming that
Static initialization is a bitch
 
2:40 AM
I'm on Linux, so it's possible that's somehow related to Cygwin.
 
I will have to try again tomorrow... And check the version of the compiler, compiler flags and so (clang and gcc I tested on cygwin)
 
g++ 4.5.3 on cygwin prints 5 just fine
 
> Otherwise such a variable is initialized the first time control passes through its declaration; such a variable is considered initialized upon the completion of its initialization. If the initialization exits by throwing an exception, the initialization
is not complete, so it will be tried again the next time control enters the declaration. If control enters the declaration concurrently while the variable is being initialized, the concurrent execution shall wait for completion of the initialization. **If control re-enters the declaration recursively while the variable is being initialized
 
Or maybe it's been fixed on of the 4.6's revisions.
 
6.7 Declaration statement [stmt.dcl] paragraph 4 (n3290).
 
Xeo
2:42 AM
@LucDanton Yeah, except that it never does the last part.
Maybe that code should've been if(!n) return 5; ?
 
@Xeo To prove something is correct, you have to quote the Standard. Which I did.
 
Kind of strange, because it produced a quite explicit error: initialization through a recursive call (absurdly it was an exception, that you can catch and ignore, not that that would solve the next call....
 
Xeo
I was just too lazy to open my paper and tried to search my answers where I already quoted that part. :P
 
@LucDanton But you adulterated the quote! I'm pretty sure the standard doesn't make use of asterisks like that.
@Xeo lol
 
7 mins ago, by Luc Danton
Surely you mean favourite Standard?
 
2:43 AM
@Luc: My quote seems to contradict your quote.
 
Xeo
But then my damn router kicked in and butchered my internet connection.
 
@RMartinhoFernandes Attempt at emphasis is mine indeed.
 
@Xeo, damn typing on an iPad... It is if (!n), otherwise it would be simple.
 
Xeo
2:44 AM
...
sigh indeed
 
@BenVoigt About initializers? In what way? And what does it contradict?
 
Xeo
Why do you think we were all so wary? :P
@BenVoigt I think the part before that deals with constexpr initialization
Yeah, then indeed it's undefined behaviour.
 
@DavidRodríguezdribeas Haha, I thought that if wasn't entered and lead to UB in the first place.
 
@Luc: From 8.5 "Except for objects declared with the constexpr specifier, for which see 7.1.5, an initializer in the definition of a variable can consist of arbitrary expressions involving literals and previously declared variables and functions, regardless of the variable’s storage duration."
 
And the fact that GCC warns about it in later versions is by design IIRC. Has to do with the C++11 requirement of concurrent initialization, so they threw the check in I think.
@BenVoigt What is being contradicted?
 
2:46 AM
No constexpr here, so the initializer is allowed to be an arbitrary expression including a recursive call.
 
Xeo
@BenVoigt Yeah, the call itself is fine
But not that the variable is attempted to be initialized again inside the recursive call
 
@LucDanton 4.8 doesn't warn.
 
@BenVoigt Yes. That's not a contradiction.
 
Xeo
That is explicitly marked as "Undefined behaviour"
 
All I'm missing is -Weffc++, I think.
 
Xeo
2:48 AM
Clang ToT isn't warning either
 
@BenVoigt Oh I think I can clarify. The recursive part of my quote is about control flow hitting the declaration again. Not about a recursive call to a function.
 
@R Martinho, I don't think it warns, but rather throw an exception at runtime
 
Yes, that's what happens.
 
I didn't mean compile-time diagnostic, sorry.
 
$ make gcc-test -B
g++-4.8 -std=c++11 -Wall -Wextra -Werror -pedantic-errors -I/home/rmf/dev/wheels/include -o gcc-test test.cpp
$ ./gcc-test
terminate called after throwing an instance of '__gnu_cxx::recursive_init_error'
  what():  std::exception
Aborted
$
 
2:54 AM
AugH chatting on an iPad is so awkward lol
 
Xeo
@RMartinhoFernandes So it does non-trivial checks at runtime without being asked?
Or is that from -pedantic-errors?
 
@Xeo No, -pedantic-errors is a request for compile-time diagnostics.
@Xeo It's not non-trivial.
It's simply a matter of using a non-reentrant lock.
 
Xeo
Does it also throw that with -O3?
 
@Hoxleboy... Almost 2 months living off an iPad :) (and a kindle for reading)
 
2:57 AM
11 mins ago, by Luc Danton
And the fact that GCC warns about it in later versions is by design IIRC. Has to do with the C++11 requirement of concurrent initialization, so they threw the check in I think.
There's already some code that checks whether the initialization is reentered, so that check comes in fact for free.
 
@luc, the exception was there from way back in 3.4, and in 4.5 it became worse with multithreading support: deadlock
Then it was fixed in 4.6
 
I see.
 

« first day (514 days earlier)      last day (4417 days later) »