Talk:Sokoban: Difference between revisions

 
Line 36:
:: Right, using assert() as allocation guards is a bad idea, maybe it's better to remove those asserts. You can't assume no one will compile your code with NDEBUG defined. Putting non-pure code inside assert() is often a bug waiting to happen.
:: Regarding const, it's also a contract between the programmer and the compiler, it says that something hopefully will not change (in D language this is enforced much better than C), this makes the code simpler to understand too. Every variable that doesn't need to change must be const/immutable, if practically possible: http://blog.knatten.org/2011/11/11/disempower-every-variable/ --[[User:Bearophile|Bearophile]] 00:06, 15 May 2012 (UTC)
 
::: I don't know, I'm not one into following good practices (not that I suggest you do the same). <code>const</code> is at most a moral contract, it can't serve as a contract that garantees logical invariance: you can always find a way to cast a const pointer into something else. For library code that users don't normally see the source, I do use <code>const</code> as a hint, but for local code, I don't really care. Same goes for things like <code>(void) printf(...)</code>: I don't think it does real harm, but it's pointless. It's probably just me, though. --[[User:Ledrug|Ledrug]] 01:14, 15 May 2012 (UTC)
Anonymous user