« first day (640 days earlier)      last day (4294 days later) » 

7:01 PM
@R.MartinhoFernandes If I stick .good on the end it works. I fucked up.
 
@MooingDuck oef is bad. In fact, it needs to be. Except when you read MSDOS text files in text mode, where ascii 26 (^Z) may still have been used to signal EOF
 
Is while (infile && !infile.eof) valid?
 
if(mystream) is equivalent to if(!mystream.fail()) not if(mystream.good()).
@Drise Because infile == true implies !infile.eof(). It's expected.
24 mins ago, by R. Martinho Fernandes
Don't bother with good(), bad(), and ugly(), oops, I mean eof(), just use the conversion to bool.
I meant it.
 
@R.MartinhoFernandes Example? I hate to be thick headed but
 
@Drise valid, but it doesn't add anything. The stream will still be considered 'good' until the 'past-the-end' read is attempted
 
7:03 PM
@R.MartinhoFernandes yeah, they are GregorianCalendar
@Drise don't check eof ever, nobody ever does it right
@sehe you certain? That doesn't sound right
 
@R.MartinhoFernandes yup /cc @Drise it's the only portable way. Relying on early (OS/filetype-dependent) eof signalling is not portable
@MooingDuck oh ^ /cc you too then
 
@sehe I know I'm going to regret saying this. But that's what my university taught me to do.
 
@Drise they taught you wrong. (so did mine, and every other university I've heard of)
 
/cc ?
 
@Drise No you won't regret it. You just gave yourself a good lesson.
@JimNorton carbon copy, it's pre-internet speak for 'send a copy to'
 
7:06 PM
@sehe ah... ok
 
@sehe I fucking hate university taught language ... semantics?
 
@Drise No, you're confused. The thing is: you'll inevitably learn habits the wrong way since you used not to know better at first. The university is only instrumental in getting you those first (wrong) impressions
 
Universities suck at C++.
11
 
@Drise while (mystream >> myobject) //dostuff
 
We're much better.
 
7:07 PM
@MooingDuck Can't. Must use readline(). It does a whole bunch of line processing.
 
Mostly, because experience gathers here. Experience is better.
Experience and rigorous zealotism
 
@Drise while(readline(mystream, mystring)) //dostuff
 
Xeo
@Drise while(std::getline(stream,string))
 
@Xeo readline is a function in his code for homework
 
Just, stream& s; while (s) { /* do stuff */ } in general
 
7:09 PM
@Drise can you change the return type of readline?
 
Xeo
as long as it returns the stream, then it's fine.
17
Q: Why is iostream::eof inside a loop condition considered wrong?

MAKI just found a comment in this answer saying that using iostream::eof in a loop condition is "almost certainly wrong". I generally use something like while(cin>>n) - which I guess implicitly checks for EOF, why is checking for eof explicitly using iostream::eof wrong? How is it different...

seems relevant btw
 
@Drise `if (! (mystream>>myobj)) return; //failed to read new line, done reading
 
Hold on. I'm getting very angry at myself.
 
@Drise the best way forward after your 'college primer' would be: get some real experience (not even in C++ necessarily; lot's of good habits and insights to be picked up programming anything at all). That, and use Stack Overflow as an accelerant:
Jun 14 at 21:56, by sehe
@Drise from just reading the other answers you'll learn way more than from asking the questions you could come up with yourself. That's the way I picked it up
 
Xeo
And making wrong answers yourself helps too
Don't fear the downvotes, they teach you too.
 
7:12 PM
Yup. I was quoting from a conversation that encourages exactly that.
 
@sehe No. See this bug has just been distributed as part of a BETA release. Because my university teaches shit for C++
And it's taking a giant shit on my face.
 
@Drise What bug? Ladiebug? Chinese tiger mosquito?
 
@sehe end of line file reading
 
@Drise What, do they still have beta releases for Borland C++ 3.1?
 
@Drise I had the advantage of my university not teaching any C++. Left me able to learn it for myself. Which I should really get around to sometime.
 
7:14 PM
I don't get it? A source bug in a beta release of a product?
 
@sehe This is part of a product my company is developing. A lot of pressure has been put on me because sometimes it works, sometimes it doesn't, and I'm the only one who knows why. At least, can figure out why.
 
@Drise Oh. I see :) Well, good news, I see you already started down the good path: picking up experience. There is no substitute
As any cyclist knows: there is no susbstitute for the pain of making beginner errors
 
Ok so.
mystream.good()
What does it do.
 
@Drise doesn't matter, don't use it use bool(mystream)
 
@Drise For sure it doesn't read the documentation for you
@MooingDuck You might, you know. It is quite useful for literate coding when e.g. writing your own extraction operators or io manipulators
 
7:16 PM
@sehe possibly. I used .eof once
 
Oh god... first link on reddit today:
I've never even heard of half the things in that resume...
 
@MooingDuck After a stream goes 'bad' you can use it to discern: (a) regular eof (b) IO error(s) or (c) extraction failure
 
@MooingDuck Still fails.
 
@Mysticial Well, I didn't scan anything I didn't know. But I wouldn't hire since if the code organization (heck, thought structures) even /resemble/ the organization levels in that document, there isn't a coherent thought to be had.
@Drise Then your problem is elsewhere. Post it on Stack Overflow proper
 
I wouldn't hire because that resume is obviously BS...
 
@MooingDuck I think that may work.
 
@Drise Where is it? Link? Failing test case?
 
36 mins ago, by Drise
http://ideone.com/O6aB3
 
Failing test case? What should it do? When?
 
I should just give you guys a test file and tell you to parse it, and see what you come up with. Anyone game?
 
7:23 PM
Oh, why not:
 
@Drise what's wrong with the code I just told you?
 
#include <iostream>

std::istream& readline(ifstream &inFile) {
  //getline...  //do other things
  return inFile;
}

int main() {
    while (readline(mystream)) {
        std::cout << inFile.good() << inFile.eof() << '\n';
    }
}
@Drise Nope. Stack Overflow is the place to be for that. And yes, I'd be game
 
@sehe you don't have a bailout between getline and dothings, I think that was the problem
 
@MooingDuck Well I could assume that the problem is before/inside the while loop... hard to tell from a sketch
 
7:28 PM
Ha, @cHao got flagged in the JS room for insulting Canada.
 
:)
 
I am so offended right now.
 
there's some canadian in there ranting about the us
 
I feel like 12 years old.. being really satisfied with this answer, working on the constexpr float to fractional thingie right now.. it's gonna be ace!
3
A: C++: Why can't I use float value as a template parameter?

refpTHE SIMPLE ANSWER The standard doesn't allow floating points as non-type template-arguments, which can be read about in the following section of the C++11 standard. 14.3.2/1      Template non-type arguments      [temp.arg.nontype] A template-argum...

 
Well, well.
 
7:29 PM
@cHao Why?
 
So it has come to this.
 
@SamDeHaan Sorry, but I'm not really into Pokemon
 
apparently he thinks he could run the us better or something? i don't freaking know. but he apparently loves complaining about us
 
-1
Q: Qt Designer and Custom MainWindow class

NilsI designed my app in the Qt Designer. The main window as well as all the widgets are loaded at runtime from the UI file using the QUiLoader class (no code is generated by the designer). Now I realized that, in order to save and restore the state of the window correctly I need a custom main window...

Is my question really that bad formulated?
 
I don't know QT, so my confusion is an invalid measurement. (I don't know)
excellent, the Calendar class is telling me that my meeting is at 213:20pm on the first day of the 30th month of the Gregorian calendar. I hate Java.
 
7:33 PM
@MooingDuck Why are you doing it in Java?
 
@AgainstASicilian Work.
 
lol
 
Though honestly the management all hates it too, and is willing to let me to convert it to C# if I can translate all 1119 files and 31 java dependancies in less than two weeks.
 
0
Q: How would you parse this file?

DriseI have a file: <MY_TAG1_BEGIN> #My file comment SOMESTRING = thisisafile.txt SOMEINT = 5 <MY_TAG1_END> <MY_TAG2_BEGIN> # SOMEOTHERDOUBLE = 1.0 #This line should be ignored SOMEOTHERINT = 5 <MY_TAG2_END> <MY_TAG3_BEGIN> SOMEOTHERDOUBLE = 1.0 SOMEOTHERNEW...

Have at it.
 
@Drise no.... That's not a real question >.<
 
7:36 PM
FML
 
Parse it like a saltshaker
 
NVM
I'm afraid I'd get fired for that.
 
@Drise that's a rather complicated and strange file format
half xml and half.... something that's whitespace sensitive.
 
@MooingDuck Tell me about it.
 
The right way is probably a lexer + a simple parser
but there's probably an easy way too.
 
7:39 PM
@MooingDuck Lexer? Also, mine is just a bunch of if statements
 
@Drise a class that you give it a file, and call get_symbol() and it gives you the next word/symbol/whatever in the file. It's a compiler term.
 
@MooingDuck Note also: Your code works, so far.
 
@MooingDuck It's not complicated, just unusual.
 
@Drise it should, I followed all the rules and stuff
 
he's only got like, 4-5 tokens
 
7:41 PM
@MooingDuck Give it a day or two and someone will break it and my headache will resurface.
@DeadMG Try about 120. Each SOMEDOUBLE is important
 
<, >, identifier, =, number, .
 
@DeadMG on second look, the "tags" aren't really xml, and and so I guess yeah. One line at a time. should be easy
 
@DeadMG You can likely just use regular expressions
 
that's it
 
@Drise all identifiers are a single token
 
7:42 PM
i use -pedantic, -pedantic-errors, -Wfatal-errors and it compiled fine — xst 2 mins ago
 
@Drise So keywords?
 
Wut ^ does he mean he's right ?
 
@DeadMG yea, I think.
 
if you just have a giant list of keywords, it's easier to handle them after parsing
 
@Drise it's hard to get far since we don't know the intended format. What to do with the data.
 
7:42 PM
else you'll just introduce 99999 special cases.
 
@Drise Always provide you're best shot at it. Otherwise people would have to come up with the whole shit from scratch, which they won't.
 
best to just let the parser/lexer call them "identifier" and let the analyzing code check if they're the right identifier in the right place
 
@MooingDuck each MY_TAG is a seperate structure.
 
Strip out the garbage first to normalize it, then parse the common residuals
 
See, this is my company's code. They paid for it (by paying me to write it). I don't know how much I can disclose.
 
7:45 PM
well, we only really care about the form
 
I'm working on a little game as a bit of a side project; and I was wondering, what's the best way to dynamically load code at runtime into the game?
 
@Drise I'm coding stuff, hold on a sec
 
Woot. I just repcapped. I don't know how, since I mostly got residuals. Just aced to questions, bam. That was easy. Now I can get back to working...
 
Like if I want to stream code to it through a network connection or something (have code built into each level)
but also keep it reasonably secure against attack.
 
use scripting language is the usual solution
@Drise Ultimately, you have a super-simple structure, from a lexical/grammatical point of view.
six tokens, and only three rules with simple left recursion
 
7:49 PM
What in the world...
 
How's IDEOne do it?
Without having some hacker crash their whole system
by uploading a malicious piece of software?
 
sandbox
 
@DeadMG So probably scripting+sandbox is the best way to do it
 
scripts are dead simple to sandbox
 
So first I should write a compiler to compile scripted code from C or something
 
7:50 PM
@DeadMG Are you no longer a puppy?
 
or C++
 
@IDWMaster What, no.
use an existing
Lua, JavaScript, Python
 
@IDWMaster Or use one of the many already established scripting languages
 
@Drise BNF grammar and token list.
 
@DeadMG I have no idea what that is.
 
7:51 PM
@Drise It tells you WTF to code, OK? :P
 
@Drise Still not interested in Boost ? I could roll a Spirit parser...
 
In computer science, BNF (Backus Normal Form or Backus–Naur Form) is one of the two main notation techniques for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocol; the other main technique for writing context-free grammars is the van Wijngaarden form. They are applied wherever exact descriptions of languages are needed: for instance, in official language specifications, in manuals, and in textbooks on programming language theory. Many extensions an...
Tada!
 
it's simple
 
@sehe No boost. Sorry.
 
step 1 is lexing- you categorize each useful subsection of the file into a type.
identifier, <, >, etc.
 
7:52 PM
@Drise It's ok! Lots of other things to do :)
 
also you strip comments and whitespace here
 
I awarded my first 500 points bounty :)
57
A: Why is the Java main method static?

Kevin DayThis is just convention. In fact, even the name main(), and the arguments passed in are purely convention. When you run java.exe (or javaw.exe on Windows), what is really happening is a coupleo of Java Native Interface (JNI) calls. These calls load the DLL that is really the JVM (that's right ...

 
then the parser sees a list, stream, iterator, whatever of tokens.
those tokens match the BNF rules I gave, which dictate the form they must take to be well-formed.
you will see that it is very simple to go from (such a simple) BNF to a very simple parser
and the output can also be absurdly simple
Drise, you still here?
 
@MooingDuck Broke it.
 
1
Q: Gdb on MacOSX lion

bsreekanthI am new Mac user, and wonder how to install latest version of gdb (>7.1). I prefer to use home brew, but could not find gdb listed. brew install gdb Error: No available formula for gdb Please help with the best way to do it. When installed XCode, it may installed an older version. Currently...

Why does it have to be so painful!?
 
7:58 PM
@DeadMG Yes, but breaking things. I'd like to see how you'd do this lexer thingy.
 
it's best to simply write a proper parser and lexer the first time
if you don't know language implementation basics, you won't get it right
simple
a lexer is basically a regular expression
you match it against the contents of the file
 
@MooingDuck NOTE: NO C++Ox!
 

« first day (640 days earlier)      last day (4294 days later) »