Forum

for those working on dos quake ports

Discuss anything not covered by any of the other categories.

Moderator: InsideQC Admins

Re: for those working on dos quake ports

Postby Baker » Thu Mar 01, 2012 2:46 pm

mh wrote:Your Memory_Free doesn't do what you think it does, by the way, and you're modifying some const params in other functions.


I figured that out and corrected in my prototype and was hoping no one would notice and say something like that. :D I started comparing memory addresses of variables during execution and I noticed that.

Not sure if that's a big deal here (const rules make my brain melt - a lot of modern code seems to be just a wall of "const" noise that it's difficult to pick much signal out of, plus they're only compile-time safety that can be circumvented if you get tricksy so I'm naturally suspicious of a false sense of security here - C++ 11 should have really defaulted to const for everything with needing to explicitly specify non-const


I don't like littering everything with const. I've actually been rethinking that lately and might reserve doing so only for certain types of variables like "strings". I just worry about a typo doing something bad and const has been rather useful protecting against accidents.

I previously was a rather big on static for any local function, and I have stopped doing that completely (for now at least). What I do instead is prefix those functions with lowercase "s" (so I can see the function isn't supposed to be externally access) and rely on whether or not the function prototype is at the head of the source file or in the header.

All the ins and outs of C ... much to learn about, but strangely satisfying.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: for those working on dos quake ports

Postby mh » Thu Mar 01, 2012 6:06 pm

const is really only of use for pass-by-reference anyway; if you pass by value then the value will be pushed and popped on the stack and modifying it in the function will achieve absolutely nothing. Sometimes it's useful to temporarily modify a value and have the original restored by this method (although you'd better add a comment explaining that this is the behaviour you want).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests