Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 25, 2024, 12:38:18 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Writing your own code...
Pages: 1 2 3 [4]
Print
Author Topic: Writing your own code...  (Read 3719 times)
jolene
Guest
« Reply #60 on: October 22, 2014, 12:23:23 PM »

"hey i want to start coding, how do i do that?"

ubik: i recommend you start using linux. also here's an unprompted rant on sjws
Logged
Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #61 on: October 22, 2014, 12:35:45 PM »

If you need the resource to be freed then that's fine but if you just want a block of code why bother to do the idisposable dance? you could declare it locally in the block.

Because if I do this:

Code:
_shader.Activate();
_shader.Stuff();
_shader.Deactivate();

And an exception happens in Stuff(), it won't deactivate it again. Of course I could put it in a finally block but that would take up even more space. I really want to do this in proper C++ style RAII, but unfortunately this is the only way I can get anything like a deterministic destructor in C#.
Logged
jolene
Guest
« Reply #62 on: October 22, 2014, 12:37:39 PM »

For short statements like in your example people do it all the time, I don't see anything wrong with it. Just remember to fill in spaces so that statements are aligned horizontally:

Code:
select(a)
{
   case 0:   b = 2;   break;
   case 1:   b = 425426;   break;
   case 2:   b = 32432431262;  break;
   default:  b = 0;   break;
}

thats dum cos im going to change the values like this
Logged
Netsu
Level 10
*****


proficient at just chillin'


View Profile WWW
« Reply #63 on: October 22, 2014, 01:02:19 PM »

Then you can readjust all the lines accordingly, obviously, or revert back to a multiline setup.
Logged

ThemsAllTook
Administrator
Level 10
******



View Profile WWW
« Reply #64 on: October 22, 2014, 01:43:53 PM »

I've always felt like that particular problem could be solved by intelligent rendering of tab stops. If text editors would treat tab characters after non-whitespace characters as vertical alignment markers and adjust consecutive lines of text to match up, you could just use tabs to align all that. I suppose you'd have a problem if two tab-aligned sections of code were right next to each other, though...
Logged

InfiniteStateMachine
Level 10
*****



View Profile
« Reply #65 on: October 22, 2014, 01:50:21 PM »

If you need the resource to be freed then that's fine but if you just want a block of code why bother to do the idisposable dance? you could declare it locally in the block.

Because if I do this:

Code:
_shader.Activate();
_shader.Stuff();
_shader.Deactivate();

And an exception happens in Stuff(), it won't deactivate it again. Of course I could put it in a finally block but that would take up even more space. I really want to do this in proper C++ style RAII, but unfortunately this is the only way I can get anything like a deterministic destructor in C#.

Ah yes so you do need to release the resource. I thought you were implying you wrap everything like that regardless of whether or not it needs to be freed
Logged

Impmaster
Level 10
*****


Scary, isn't it?


View Profile WWW
« Reply #66 on: October 22, 2014, 05:49:54 PM »

posting to follow, cause im a nooby coder and i gotta get good
Logged

Do I need a signature? Wait, now that I have a Twitter I do: https://twitter.com/theimpmaster
Pages: 1 2 3 [4]
Print
Jump to:  

Theme orange-lt created by panic