TheU.ca Forum Index - General Discussion - If I may be so spiteful... - Reply to topic
|
Senther
Xtalk Drifter Joined: 29 Jun 2006 Posts: 2296 Location: The Deadlights ![]() ![]() votes: 42 View user's profile |
Personally, I usually would put the (assuming defined type sexuality and gay is defined): Code: int arson(sexuality arsonist)
{ if(arsonist == gay) return 0; else return 1; } Unless my code was getting terribly long, then I'd reduce the inside to two lines. The exception is that I almost always keep looped single statements on one line, even if nested. However, I'm a strong believer in global variables. Mostly because I'm lazy when it comes to passing arrays, but also because of the limited stack inside main (or whatever CSci people call that). _________________ To avoid complications, she never kept the same address In conversation, she spoke just like a baroness |
|
Senther wrote: Personally, I usually would put the (assuming defined type sexuality and gay is defined):
Code: int arson(sexuality arsonist)
{ if(arsonist == gay) return 0; else return 1; } Unless my code was getting terribly long, then I'd reduce the inside to two lines. The exception is that I almost always keep looped single statements on one line, even if nested. However, I'm a strong believer in global variables. Mostly because I'm lazy when it comes to passing arrays, but also because of the limited stack inside main (or whatever CSci people call that). In that case, you would have to Code: typdef sexuality to something meaninful, and "gay" would be a static instance of a sexuality-typed variable. I'm a stong believer in non-global variables, as there are more sensible ways to do things (eg. stateful objects?). Global variables mess up all the scopes, and make the code confusing. |
|
Apocalypse
The Director Joined: 22 Nov 2007 Posts: 693 Location: [CLASSIFIED] ![]() ![]() ![]() ![]() ![]() ![]() votes: 4 View user's profile |
enmand wrote: Code: typdef sexuality or, even better.. Code: typedef enum { gay, straight } sexuality;
I love how a gay parade thread was turned into a programming practices discussion _________________ Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor. |
|
Jimmy Big Ears
X-talk mobster Joined: 13 Sep 2006 Posts: 3256 Location: St. Francis Xavier University ![]() ![]() votes: 38 View user's profile |
This is probably the greatest triumph of computers over relevance. I am going to bring this up the next time anyone here insists they care about issues. _________________ "Ah, sleek vigilant puma. Principal of the mountains." -Seymour Skinner. |
|
pedal2000 wrote: Cheers it appears to start after one this year
/\ Thread's purpose ended. It's pretty open field after that |
|
Senther
Xtalk Drifter Joined: 29 Jun 2006 Posts: 2296 Location: The Deadlights ![]() ![]() votes: 42 View user's profile |
Apocalypse wrote: Code: typedef enum { gay, straight } sexuality; This is what I was thinking of. My preference for global variables is probably due to the differences in why we code. Some days, I might throw half a dozen or more quick programs together for parsing data, or what have you. In that case, throwing something above main is not only easier, but avoids a lot of pitfalls with big arrays. I'm also terrible for using system calls in place of longer (but more efficient) routines. Only when I'm working on something intended for others (or modding existing code, like Q3 source) do I try for elegance. Oh, and Jimmy, feel free to post in a different topic you don't understand. There's lots to choose from. _________________ To avoid complications, she never kept the same address In conversation, she spoke just like a baroness |
|
Jimmy Big Ears
X-talk mobster Joined: 13 Sep 2006 Posts: 3256 Location: St. Francis Xavier University ![]() ![]() votes: 38 View user's profile |
Oh squawk squawk squawk. pedal2000 wrote: pedal2000 wrote: Cheers it appears to start after one this year
/\ Thread's purpose ended. It's pretty open field after that I am going to talk about the possibility of another Star Trek movie. I hope no one drops out of the cast but they could use a slightly better storyline than the one they had. Leonard Nimoy ought to get involved - he directed two of the good ones. _________________ "Ah, sleek vigilant puma. Principal of the mountains." -Seymour Skinner. |
TheU.ca Forum Index - General Discussion - If I may be so spiteful... - Reply to topic