3,544 reputation
819
bio website
location
age
visits member for 3 years, 4 months
seen 22 hours ago

Oct
5
reviewed Reject suggested edit on Why do some projects have getters and setters for public instance variables?
Oct
5
comment When writing object-oriented code, should I always be following a design pattern?
As a secular programmer, about all I can say is "OMG, this answer is fantastic!" (as are the comments). Telastyn, Cerad, and tobyink, you three came this close to owing me a new computer monitor. It's a good thing my mouth was empty of liquids when I read this answer and the comments.
Sep
30
comment Derive subset with sum between two values
Solutions to the knapsack problem inevitably use what you call "guess and check".
Sep
30
comment Derive subset with sum between two values
Re Is there an algorithm to get the desired subset without using guess and check? Let M be the number of questions whose ranking is between 0.65 and 0.75. The answer to your question is yes if M>N. Just randomly choose N of those M questions. Otherwise, the answer is no.
Sep
30
comment Derive subset with sum between two values
What does that even mean, Preston? You have not fully specified the problem.
Sep
30
comment Derive subset with sum between two values
With the given example, 200 questions of which 50 are to be chosen, finding all the subsets of 50 that meet the requirement and choosing one at random is an unachievable task. There are 200 choose 50, or about 454 quattuordecillion (454*10^45), possible subsets. Some will be acceptable, others not. Your computer doesn't have the capacity to find all the acceptable subsets. Even Google or the NSA doesn't have that much storage (it's not even close).
Sep
30
comment Derive subset with sum between two values
@PrestonS - So what? This comment of yours suggests you have some addition requirements that you have not yet told us.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
It would have helped a lot if the question had made it clear that GhostDoc automatically generates comments from uncommented code. Having that key piece of information hidden behind a link that appears as just a four letter word is not good form.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
@KyleStrand _ I stand corrected. Doxygen does not produce such nonsense. Doxygen reads but does not generate doxygen comments. Those doxygen comments need to be written by a human.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
@cdorking: As far as how to tell what was auto generated, look at this page that describes a function deep within the guts of Eigen. The calling sequence is autogenerated. Much of the text below the calling sequence is hand-written. The math is hand-written LaTeX that doxygen automatically processes. The list of parameters: The names are autogenerated, but the meaning of those parameters comes from hand-written commentary. The list of functions referenced within is autogenerated.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
@cdorking: You misread the question. Read it again. GhostDoc was not attempting to read the programmer's mind. That goofy phrase appeared precisely because a programmer explicitly wrote that phrase as a comment to be parsed by GhostDoc. GhostDoc doesn't know what that phrase means. Like doxygen or javadoc, GhostDoc reproduces key commentary hand-written by humans as-is (plus formatting). There is no mind reading going on.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
-1. Just pretend? That might work great for a one person project that will never be used again. Some level of documentation/commentary is needed even with a one person project if it's complexity is greater than that of "hello world" and if you plan on picking up that project in six months time. In a project involving dozens or even hundreds of people, failure to document/comment can kill the project.
Sep
11
comment Is there any logical reason to auto-generate code documentation?
@dcorking _ I haven't the foggiest idea what you mean by that. Doxygen can't read the programmer's mind. For a good example of what doxygen can do, see this top-level page for Eigen, a rather popular C++ scientific computing package. Poke around! You can see some documentation that's obviously written by humans, other that is purely auto generated, yet other that is a blend of human-written and auto generated. If told to, doxygen will automatically generate fan-in (who references this function) and fan-out (what does this function call).
Sep
10
comment Is there any logical reason to auto-generate code documentation?
Actually, it's both. doxygen parses the code and the doxygen comments. Class names, parent class names, data member names, function names, argument types and names, return type: Those all come from the parsed code. What those things mean come from the doxygen comments. Doxygen complains if an item specified as a \param in the doxygen comment isn't an argument, and it can be made to complain about undocumented items. Other than these minimal checks, the problem of comment vs code mismatch is still a possibility. That said, I love doxygen. It's much better than writing an API by hand.
Sep
7
revised What's the list of how to precisely talk about problems in C++ code within the spec?
added 2034 characters in body
Sep
7
comment What's the list of how to precisely talk about problems in C++ code within the spec?
You missed a category: Errant code for which no diagnosis is required, with a well-defined response at run-time. Two examples: A still-joinable thread going out of scope, and an exception propagating out of a function marked as noexcept(true). These are errors, but no diagnosis is required. The run-time behavior is well-defined rather than UB: A compliant implementation must call std::terminate for both. (From my reading of proposals to the standard, there was a strong inkling to make both of these UB rather than a well-defined call to std::terminate. But that didn't happen.)
Sep
7
comment What's the list of how to precisely talk about problems in C++ code within the spec?
Three suggestions: (1) Just delete the joke. (2) Understand what undefined behavior is. UB represents two very different thing to compiler writers and programmers. To a programmer, it's the tenth circle of Dante's Inferno (Dante only had nine circles). To a compiler writer, it's a "Get Out of Jail, Free!" card. You don't have to detect it, and if you do detect it you don't have to issue a diagnostic. The halting problem does not exist to a C++ compiler writer. If you see while(1); you can make it go away. Suggestion #3 is forthcoming.
Sep
7
comment What's the list of how to precisely talk about problems in C++ code within the spec?
And yes, DeadMG is absolutely correct about failure to terminate being undefined behavior, at least in C++. It's very explicit in the standard. While the halting problem is in general impossible, seeing that while(1); doesn't terminate is easy to detect. The standard expressly allows compilers to optimize such loops away. (But please tell me you did that!)
Sep
7
comment What's the list of how to precisely talk about problems in C++ code within the spec?
Unhandled exception is not a compile-time error. It can't be. This is the halting problem all over again. That said, the compiler can detect obvious cases such as the one illustrated in my answer. Just because you are free to ignore the problem doesnt mean you must ignore the problem. There's a vast difference between a compliant compiler and a compiler that is useful and compliant. You should strive to be writing a good compiler (that is of course compliant).
Sep
7
answered What's the list of how to precisely talk about problems in C++ code within the spec?