« first day (657 days earlier)      last day (4517 days later) » 

17:00
@JerryCoffin Oh gawd, I didn't even notice that.
@R.MartinhoFernandes Of course, there is a certain degree of hilarity to be had from somebody worrying that much about the appearance of code, but at the same time writing Perl.
@JerryCoffin Yeah, I linked it for the Perl. But the check he wants to is really great.
I suggest you stop wasting your time and use something that's already out there, such as uncrustify. You can call the executable from Perl if you must. — Prætorian 24 secs ago
A beautifier is reasonable.
A tool that spits on your face if you miss a space is a seriously bad idea.
Yep, and I've used that one myself. It has options for spaces around the if, plus a million other options
Oh, he wants to catch styles errors? Not fix them automatically?
17:09
What I want is if the code does not following following guidelines then throw an error
hmm, I seem to have gotten in a debate as to if fixed point is "a concept laid over integer arithmetic", or if it is "a specialcase/optimization of rational arithmetic". I think both are equally valid.
@Prætorian There's also gnu indent. They all have so many options that conflict in so many ways that unless the code has been intentionally obfuscated (or something on that order), it will always come out worse than it went in.
@R.MartinhoFernandes "context sensitive grammars"? No, at least not as the CS term, because CSGs can be impossible to decide. You can however add "context" by using lookaheads/lookbehinds and, more importantly, writing a suitable grammar (a * b; has to mean "a times b" not "a pointer b") — amon 2 mins ago
To parse C++, parse a different language instead.
17:11
@R.MartinhoFernandes That does make the job much simpler!
I don't think I ever really understood what a "context sensitive grammar" is?
It is a grammar where you can look at the surrounding tokens when replacing non-terminals.
is it just that the use of a particular terminal/non terminal depends on context?
@TonyTheLion do you know what a * b is in C++ without context? If not, it's context sensitive.
17:13
@MooingDuck That has nothing to do with context-sensitive grammars.
@FredOverflow researching... :(
@FredOverflow non-terminals are the things you replace in the grammar right, like variables etc?
If each rule of C++ syntax has the form "NonTerminal -> whatever", then it is context-free.
@TonyTheLion A CFG has productions of the form A ::= whatever. A CSG has at least one production of the form aB ::= whatever -- i.e., B is defined in some particular way only in the context of a. In this case, a would be a previous declaration saying whether a is a type or a variable.
@TonyTheLion Non-terminals are the things you replace, right. For example "expression" or "statement".
@JerryCoffin Why did we both chose "whatever" instead of "foobar" or something else? Must be the phase of the moon or something ;)
17:15
so in A ::= whatever, which is the terminal and which non-terminal?
@FredOverflow Not sure about you, but I almost never use foo, foobar, etc.
@JerryCoffin aBc ::= a whatever c.
@MooingDuck Don't be too sad. As long as you remember that C++ has a terrible syntax, you're fine. The theoretical basis for why it sucks doesn't matter that much.
I like thingy as a metasyntactic variable.
@TonyTheLion A is the non-terminal.
17:17
@TonyTheLion Not necessarily either. A terminal is something that comes from the lexer. Anything you construct from a sequence of terminals is a non-terminal.
ah, I see
A terminal is non-divisible.
It terminates.
terminal = leaf node
int would be a non-terminal then
It's a leaf in a parse tree.
17:18
A terminal is something you actually find in your source file, like literals and identifiers and keywords and operators and puntuators and such.
@CatPlusPlus 14 would be a terminal, but it's divisible by 2 and 7. :-)
because int would be something deduced from lexical analysis
@TonyTheLion No, int is a keyword, hence a terminal.
@JerryCoffin Depends on grammar. :.
int x = 4; this is a statement
that's a non-terminal then?
17:19
@FredOverflow couldn't you write the grammar so that each of i, n, t are terminals, and int is a non-terminal?
@JerryCoffin 14 ::= 2 7 :P
why is it so damn confusing?
It's pretty straightforward.
@MooingDuck Show me a lexer that converts int to i, n, t.
17:20
@TonyTheLion
"int is a nonterminal" has no meaning
No really C++ here.
You're arriving at it somewhat backwards. Normally one starts with the definitions upfront, not on the go
But I just felt like blaming C++.
17:20
what is 'int'? is it the name of a grammar production? or is it a sequence of tokens parsed by a non-terminal?
It's a thing. Duh.
@TonyTheLion It isn't. Can you actually find the thing in a source file? Then it is a terminal. Otherwise, it is a non-terminal (or you suck at looking through source files).
Typically in something like int i=4;, the terminals are "int", "i", "=", "4" and ";". You'd then have a non-terminal like type ::= int | short | long | char, and another for definition ::= type identifier '=' value ';'
@FredOverflow one could argue that the lexer took over some of the process. (Question is: is that a legitimate train of thought? I dunno)
@JerryCoffin so the non-terminals are more the grammatical expressions of what a 'statement', expression etc in a language should look like?
17:23
@TonyTheLion or the parts therof that aren't terminals.
and the non-terminals are matched to a particular sequence of terminals to verify grammatical correctness
@TonyTheLion No, you are speaking of rules. A non-terminal "expression" is a placeholder for any expression that is expressible in the syntax, produced by rules.
@TonyTheLion in his example, he has a non-terminal "type". which isn't an expression, nor a terminal.
ah I see
I have to read up on it, but not wikipedia, because that's just too confusing
You need the dragon book.
17:26
@FredOverflow I've heard that is the book.
it is
If we had a Definitive Compiler Book List, the dragon book would be the single recommendation. It is the Chuck Norris of compiler books. (Replace Chuck Norris with Jon Skeet if you think he is cooler.)
Someone ask the question already.
Will you marry me?
3
Or did you mean another question?
I'm sorry to say that would be another question :(
Hey, it's my turn now. You already two.
It's the Summer of Love.
17:29
lol
@ScottW As long as we don't spend our honeymoon on the Java islands...
@R.MartinhoFernandes The Google Summer of Love? :)
@R.MartinhoFernandes what?
Joel Spolsky on July 20, 2012

It’s summer here at StackHQ. Have a flower!

You’re welcome. Now on to some serious work. Can we talk about cultural anthropology for a minute? I’d like to talk about what happens when a community (online or off) gets to be about… oh, three or four years old.

Every community starts out needing to recruit members, so they tend to be very friendly to newcomers.

After a few years, an insider group of old-timers forms. They get to know each other. They know the rules. They know the history and the legends of the community. And it’s only natural to get little bit irritated when newbies show up who don’t know the rules. …

@ScottW I'm not particular fond of honey and the moon, either. Let's just blow the whole thing off, shall we?
Oh, I thought you meant "shit".
@FredOverflow I can't really agree. There's at least one other book that's worthy of recommendation -- maybe even two. Probably not three though.
@JerryCoffin Okay, go ahead.
17:32
hmm, my 32 bit configuration is targetting windows XP, while my 64 bit version is targetting windows 2000. And I have no idea how that's getting set.
probably wizards
@FredOverflow Silly bit of trivia for the day: the "honey" referred to the fact that you were supposed to drink mead (wine-like stuff made from honey) and it was supposed to last a month (a full cycle of the moon).
An entire month? Wow. Gotta refill my Viagra prescription.
@FredOverflow Compiler Design in C, by Allen Holub. No longer in print, but quite good anyway.
@JerryCoffin What do you mean "but Allen Holub", does he suck in general?
17:35
@FredOverflow You can buy it off the Internet. Just check your e-mail.
@FredOverflow Oops. Corrected. But no, he's quite good in general.
@R.MartinhoFernandes I get so many Viagra mails, I just leave them in my inbox and move the normal email to the "non-spam" folder.
lol
i dont get viagra mails
You poor thing, shall I forward you some? ;)
@JohannesSchaub-litb I don't any more either. I figure they must have realized that at my age, there's no longer any hope.
17:43
You just had a son last week!
@R.MartinhoFernandes no hope for sex life, not children
HI
@nahpr Low.
@R.MartinhoFernandes Hmm..now that you mention it, that's true. Not sure how it relates to anything, but such is life.
katy perry
heh, a few of us at work had a little discussion about how different unit test frameworks would affect build times, so after I got home I figured it'd be interesting to write a little benchmark to test it. Turns out my boss got the same idea. A minute before I was ready to send my results, an email ticks in with his benchmark code + results :)
17:48
@nahpr Is this like a free association test or something? If so, I'll save you the trouble: yes, we're all insane.
@jalf So what results did you get? And were yours a lot different from his?
this site is awesome
One of my coworkers seriously messed up yesterday. Those "branches" are all commits by the same person.
Well, we tested slightly different things. He just included the framework header and timed the compilation of that, and then Catch was about 30ms slower than CppUnit. (150 vs 180ms)
@R.MartinhoFernandes Looks like he forked up pretty badly.
4
17:51
I actually wrote a few very simple tests (along the lines of ASSERT(i == 42)), and added a main file, so we actually got some of the framework code instantiated
and for a file just containing tests, I got very much the same time from both frameworks (give or take 2ms)
for compiling that to a .o/.obj
for compiling that + the main function to an executable, Clang was a few hundred ms slower
er, Catch
not Clang
@jalf That didn't seem to fit very well...
What's the other framework?
@R.MartinhoFernandes CppUnit? Crappy old port of jUnit
that's what we currently use
And yeah, Catch's main takes a while to compile. But it's a one-time deal, so it's fine.
@jalf Ah, that thing.
We all want to switch to something better, but can't agree on what
17:53
Did you test Boost's?
@jalf My condolences. Might want to try a few more though. Boost and Google both have decent candidates.
I didn't. My boss did, and that was horrendous ;)
And Google's?
the time for his test file (which just included the header and did nothing else) was around 700ms, vs 180 for Catch
@jalf Well, being Boost slower builds are a given... :-)
17:55
We talked about Google Test a bit, but it didn't really have any strong advocates. My boss wants to just write something himself, I and a few others want to use Catch
@jalf Can't blame you much there -- Catch is definitely cool.
yup
how do one adress a particular user?
@nahpr You can't do it in private
so just @<name>
thank you
Do you guys use c++11?
17:59
Yes.
oh, curiously enough, on Windows, Catch was actually about twice as fast at compiling my test file (without main), compared to CppUnit.
no clue why
400 vs 800 ms
@jalf Your compiler probably objected to the Java-ness of CppUnit.
Haha, objected.
:)
room topic changed to Lounge<C++>: Don't tell. [c++] [c++11] [c++-faq] [fun]
I'm hoping that'll give me some leverage, since our Windows build is painfully slow atm
Quick builds aren't in the spirit of C++.
@jalf Seems like it couldn't hurt. Does he have specific ideas of how to improve on Catch, or is it NIH, or what?
I know, but the difference between our Windows and Linux builds is just plain absurd
we're talking 4 vs 20 minutes
whats the mst one of your builds have taken?
*most
18:04
@JerryCoffin somewhere in between. Apparently he doesn't care much about the API, but he wants output formatted similarly to CppUnit (so our build server can understand it), per-test timing, the ability to specify tests to be skipped, and one or two other things. All stuff we'll likely have to code ourselves, regardless of which framework we end up doing
so he figures it's faster to make something with a API similar to CppUnit, but which has those features, than to add them to Catch
Catch can output JUnit formatted results. Not sure if that's what CppUnit produces.
Creating processes on Windows is far more expensive than on Linux.
You can try glueing compilation units together.
@R.MartinhoFernandes I think it is the same, yeah. I haven't tested it, but he said he looked at Catch and found a lot of "Missing: to be done" kind of comments in the output formatting code
Not everything into one, but to reduce the numbers somewhat.
Or just compile with distcc.
Gluing TUs together is a mess.
18:07
Though that would probably not work that well.
Anything related to disk I/O seems slow on Windows as well
So make a cross-compiler on Linux.
@CatPlusPlus We do. Incredibuild on Windows, distcc on Linux
They're making a Rambo FPS.
the main differentiator is that on linux we're able to use ccache
18:08
bool Barbeque::hasCoals()
{
if(my_hasCoals == 0)
{
return 0;
}
else
{
return 1;
}

}
Use a build system with cache, like SCons.
:)) hehe
-3
Q: c++ code returning false instead of true

user1418705I am trying to figure out why my code keeps returning 0. This occurs in the .cpp file in for the functions void hasCoals()and void isLit(). They are returning 0 and not 1. ***header #ifndef BARBEQUE_H #define BARBEQUE_H #include <iostream> #include <cstdlib> #include <string>...

This code is horrible and you're a horrible person for exposing us to that.
@CatPlusPlus how/what does SCons cache?
It does pretty much the same thing that ccache does, AFAIR.
18:10
hmm, in a compiler-agnostic build system? That's pretty cool
anyway, probably not gonna happen. We just spent the last 12-18 months switching to CMake
"If you've got void functions returning anything, you've got bigger problems" lol
2
@nahpr Well... "This occurs in the .cpp file in for the functions void hasCoals()and void isLit(). They are returning 0 and not 1."
k :)
Does nullptr evaluate to false?
No, it evaluates to nullptr.
@nahpr in a boolean context yes
18:18
thank you
you can say bool b = nullptr;
and you can say decltype(nullptr) x = 0;
@LuchianGrigore Use fixed font button :D
@JohannesSchaub-litb decltype? What is that?
yep
i have lost my faith into you if you know about nullptr but not about decltype
it's a c++11 facility
:) it means "gimme the type of this"
@JohannesSchaub-litb I haven't seen or read much C++11. I know some, but not a lot.
@JohannesSchaub-litb I see.
18:21
No one's ever explained that reasonably.
why is nullptr better than NULL
NULL may be nullptr
@XavierHolt: Yeah, I somehow don't think they'd give out a homework problem with a computational intensity of 2^10000. OP: Are you sure they will give you a 10000 digit string? — Wug 31 mins ago
Jesus, 2^10000...
2^10000? That's O(1)!
2
@LucDanton Lol, no, its O(2^N) where N is 10000
18:26
Still O(1) then.
@LucDanton Just because he knows how many elements there are doesn't mean he can use 2^10000 as a constant.
It's still 2^N
Then don't say 2^10000.
@LuchianGrigore Good, but you can do better: if (((my_hasCoals == 0) == true) != false)...
er, ideone.com/hkjhm compiles in C++11 >.<
@MooingDuck Neat. Does the first one decltype(obj+'z') actually do (obj+'z') and uses that to determine the type or does it just determine the type based on the return of said function?
18:31
@Drise it only determines the type. It compiles to int, no calls at runtime.
@Drise it does it, but it doesn't.
@nahpr NULL is just an alias for 0, so you can use it in non-pointer contexts (e.g., assign it to an int -- but trying to assign nullptr to an int (or char, short, long, etc.) will give a type error.
I think @FredOverflow calls it e-type-uation.
ok thanks
@rubenvb e-type-uation?
@nahpr Please use the "respond to this message"..
18:32
@Drise it's not evaluating a value, it's "evaluating" a type. eVALuate. eTYPEuate
@Drise it evaluates the expression without side effects to determine its type.
@MooingDuck Oh, instead of e-valu-ate, got it.
@Drise llke this?
@nahpr yes
@JerryCoffin int i = NULL; is not guaranteed to work.
18:33
The exercise is: Use QUICKSORT, sort the integer array contains even number in ascending order and uneven number in descending order.

ex: input int a[6]={4,6,1,2,3,7} =>output is {2,4,6,7,3,1}
@nahpr Yes. Helps when having multiple conversations.
Interesting puzzle
@Drise cool
In C++11 maybe (`4.10/1: A null pointer constant is an integral constant expression (5.19) prvalue of integer type that evaluates to
zero or a prvalue of type std::nullptr_t....`)
What's the maximun dept inheritance should go?
18:36
@nahpr 42.
lol. i serious. :)
define "should".
@rubenvb In C++11 maybe what? Maybe it's only guaranteed to not work from C++11 on? But then why would you quote C++11? Maybe it's guaranteed to work from C++11 on? But then notice how your quote says or a prvalue of type std::nullptr_t, in which case an NPC is not integral.
@LucDanton In C, it may not. In C++98/03, it will. In C++11 it may not again.
@jalf you can cross-compile with CMake.
18:38
@MooingDuck that sounds difficult
And you could try using Qt's jom, which parallelizes like Linux make.
or wait... it isn't
easy peasy
@LucDanton Yes, I was still digging through C++03.
@rubenvb I mean for code maintenance/neatness etc.
There it just says "null pointer constanst".
18:39
@nahpr log(n) is usually safe. Much more than that, not so much.
@JohannesSchaub-litb not overly, it's just a strange predicate
@LucDanton yes, in c++11 "int i = NULL;" is not guaranteed to work. only in c++03 it was guaranteed to work
^see, that's what I was looking for. Didn't find it :(
@MooingDuck yes i had a brain fart. shouldn't be difficult
@MooingDuck or wait... how do you choose the initial element you compare against?
@rubenvb 4.10. (Same reference in fact.)
18:41
i guess you need to choose two elements, one even and one odd. no randomicity anymore unless you like endless loops.
@LucDanton but what guarantees that a "null pointer constant" is convertible to int?
@MooingDuck Rotate right one bit, and compare as unsigned.
@rubenvb I mean for 2003.
17
A: "Forced" retirement for top users

Domagoj PandžaMMO games have level caps because they're finite, not because the point is to block them from achieving more. The argument is flawed in the beginning because you can't even compare SO to an MMO. StackOverflow is based on experienced and verified users (with their hard earned reputation), they ar...

@rubenvb noting guarantees. nullptr is not convertible to int
18:41
lol, -71
@LucDanton yes. Me too.
@JohannesSchaub-litb and in C++03?
@rubenvb in c++03 it is guaranteed to work
See integral constant expression in this case.
@JohannesSchaub-litb lol, why?
oh wow. 4.10
got confuzzled.
@rubenvb Because NULL must evaluated to an integral constant expression with the value 0.
for next c++ version, committee considers to ban such tings as "0-0" as nullpointer constants
and only allows "0" or "nullptr"
@JerryCoffin yeahyeah, confuzzlement in my brainz.
18:45
@JohannesSchaub-litb what? You should know how predicates work
@JerryCoffin I don't think.... would that work?
@MooingDuck huh
@JohannesSchaub-litb ideone.com/MrTot predicate for wierd sorting
i don't understand what you are saying
@MooingDuck no. i was refering to something completely different
@MooingDuck Rereading, not it wouldn't. The odd numbers are supposed to be descending. At first, I thought it was just supposed to be even numbers, then odd numbers.
quicksort is based on looking for a "median" at the beginning. it can either be odd or be even
but in this case you need both an odd and an even median
18:47
@JohannesSchaub-litb nonsense
but you can just pick two medians
@MooingDuck why is it nonsense?
@JohannesSchaub-litb don't need to
or you do the quicksort twice
@MooingDuck how is that?
if you pick an even median, how do you compare odd values to it?
@DomagojPandža Lol that question.
@MooingDuck With a bit more thought, however, rotate right one, then compare as signed would work, but just slightly differently. It would do all the odd numbers in descending order first, followed by all the even numbers in ascending order. For your test, the result would be { 7, 3, 1, 2, 4, 6}. Still fits the written description though.
18:51
@JohannesSchaub-litb ideone.com/1OrMV. standard quicksort works just fine
@JohannesSchaub-litb all evens are "less" than all odds
all evens are "less" than all odds <- different statement than what you initially stated
I thought tree sort was pretty neat.
a coworker just sent out this puzzle ideone.com/LNeBN. Pretty simple.
What do you mean by "puzzle"?
@JohannesSchaub-litb ah, I see. I copied the quote from the question, but the sample input/output clarified.
18:56
and it does not seem to make sense. if you wanted to say "all even numbers that are less than odd numbers appear first" that is still different. "0, 8, 3, 1" perfectly fits your initial statement that even numbers are in ascending order and odd numbers are in descending order. still 8 is greater than 3.
@SamDeHaan he said it was a problem he discovered and solved, and thought he'd share it with us and see if we could also figure it out.
Ah, gotcha
@JohannesSchaub-litb how is that different? That's the exact result my code would come up with. Evens sorted increasing, followed by odds sorted decreasing. Also agrees with the given sample input/output

« first day (657 days earlier)      last day (4517 days later) »