Reputation
4,612
Top tag
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
3 19 22
Newest
 Enthusiast
Impact
~503k people reached

  • 0 posts edited
  • 0 helpful flags
  • 129 votes cast
Apr
12
comment How to deal with misconceptions about “premature optimization is the root of all evil”?
@errantlinguist: If you presented evidence of that section of code being a significant performance problem for the application, and the application as a whole was slower than it needed to be, and they still denied the need to modify the code, then it doesn't matter. You're dealing with people who are impervious to evidence-based reasoning, and thus are unreasonable.
Apr
12
comment How to deal with misconceptions about “premature optimization is the root of all evil”?
@errantlinguist: If the program really is "slow as molasses", then clearly you ought to be able to easily detect Knuth's "that critical 3%" and therefore trump any arguments against optimizing it. And if you can't detect that... then you haven't done your homework yet and you aren't ready to optimize yet. So it's not clear where the problem is.
Apr
12
comment Why doesn't the compiler complain when I try to access a non-existent array value?
@5gon12eder: I'd be curious to see how you could do runtime bounds checking on a pointer parameter variable which may or may not point to an array. At least, not without breaking ABI compatibility, since most ABIs don't pass an integer size along with pointers. Or, as in the example I provided, where you get a pointer to part of an array. I'm sure there are compilers that can emit code to do some bounds checking. But it would never be comprehensive.
Mar
25
comment Is it correct to say that a variable is an instance of a data type?
@Ixrec: Note that literals are a different kind of thing. Literals are a kind of prvalue. But you can't make literal variables, so that's a different discussion.
Mar
25
comment Is it correct to say that a variable is an instance of a data type?
@Ixrec: "If not, what are they instances of?" The type int. The C++ standard does not make a distinction between primitive types and non-primitive types when talking about what variable declarations do. So T t; declares an object of type T, no matter what type T happens to be.
Mar
25
comment Is it correct to say that a variable is an instance of a data type?
"Values of primitive types are generally not said to be instances of that type; it is reserved to objects and classes." That's not true at all. Nowhere in the standard are values of primitive types not considered objects. Nor does the definition of a variable change in any way depending on whether it is a user-defined class or a primitive type.
Mar
25
comment Is it correct to say that a variable is an instance of a data type?
PODs are objects in C++. Not all regions of memory are objects, but PODs are not just regions of memory.
Mar
22
comment Unique pointer initialisation
Actually, I'm pretty sure that C++ requires that the copy be elided. The initialization of a variable by T t = T(); is required to have a valid and accessible copy constructor, but the standard requires that no copy constructor is called.
Mar
5
comment In C, are large 'pointer chains' bad for performance or code cleanliness?
@JavaProphet: Your example did not include "long lines of referencing". Or dereferencing. That's why people are confused.
Feb
18
comment Member vs. free-standing functions with respect to interface uniformity
@JerryCoffin: A variant of that proposal has already been accepted and passed to CWG for induction (but just f(x, y) -> x.f(y), plus pointer variations). Unified call syntax is as done a deal for C++17 as anything at this stage.
Feb
8
comment Encrypted content in games
@mucaho: That requires knowing "each possible solution" beforehand.
Feb
8
comment Encrypted content in games
@Christer: "Also since that fact that encryption is used is transparent to 99.9% of the users, that isn't a valid argument for it being a horrible idea." If it makes an easter egg take up more time in development that could go to genuinely useful features, then yes, it's a horrible idea. You have spent more time on formulating your question and responses to answers than this feature deserves. In that time, you could have been writing your actual game. If it's transparent to 99.9% of users... then why should it matter to them if it's encrypted? Why spend time for 0.1% of people?
Feb
8
comment Encrypted content in games
@Christer: Your example only betrays the irrelevance of your overall question. The contents of "a secret altar outside of any quest" is, by definition, irrelevant for any game that is fundamentally about completing quests. And if your game isn't about completing quests, why do you have quests in it? Either way, the overall fact remains: you are spending a very great deal of time on something of no actual relevance to your game or your players. You should focus your very limited time and energy on things that matter.
Feb
7
comment Better to have 2 methods with clear meaning, or just 1 dual use method?
@Deduplicator: allocation vs. reallocation is... OK. It's not great to put them in the same function, but it's not nearly as bad as putting deallocation in the same one. It's also an easy distinction to make.
Feb
7
comment Better to have 2 methods with clear meaning, or just 1 dual use method?
I've seen such an API. The Lua 5.1+ allocator uses it. You provide one function, and based on the parameters it passes, you decide whether it is trying to allocate new memory, deallocate memory, or reallocate memory from old memory. It is painful to write such functions. I would much rather that Lua had just given you two functions, one for allocation and one for deallocation.
Jan
27
comment Why are reference-counting smart pointers so popular?
"they are mixed with other data." It's not so much that they're "mixed" with other data. It's easy to use the C++ type system to see what's a pointer and what is not. The problem is that pointers frequently become other data. Hiding a pointer in an integer is an unfortunately common tool for many C-style APIs.
Jan
27
comment Why are reference-counting smart pointers so popular?
Um, it's a question tagged c++ which talks about C++ features. Clearly, any general statements are talking about within C++ code, not the entirety of programming. So however "objectively" garbage collection may be in use outside of the C++ world, that is ultimately irrelevant to the question at hand.
Jan
23
comment When is it appropriate to make a separate function when there will only ever be a single call to said function?
@user61852: I think the problem he's getting at is that you don't explain why you should do that. You give guidance, but no reasoning.
Jan
10
comment What are the advantages of GLSL's compilation model?
"The trick here is that the array cannot be accessed using directly an uniform variable." That is a driver bug, not a "misunderstanding of the GLSL specification". No version of GLSL has ever declared that array indexing via a uniform is illegal, that you have to use an explicit temporary stack variable between them.
Jan
7
comment OpenGL, multithreading, and throwing destructors
@greyfade: Nonsense. If you're talking about multiple contexts that aren't shared, then its still up to the writer of the application to know which objects belong to which context. No safety is ever perfect; the question is merely what is "reasonable". It all depends on how you structure your code. You can build your application such that the objects that are owned by one context are hidden from the objects owned by another. Such that it's functionally impossible for them to be deleted while the wrong context is current.